Skip to content

Backup database

Backup database #735

Workflow file for this run

name: Backup database
on:
schedule:
- cron: "17 3 * * *" # daily
# Allows running this workflow manually from the Actions tab
workflow_dispatch:
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
PGPASSWORD: ${{ secrets.PGPASSWORD }}
jobs:
backup:
runs-on: ubuntu-latest
steps:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
- uses: actions/checkout@v3
- name: Get flyctl
uses: superfly/flyctl-actions/setup-flyctl@master
- name: dump the database
run: |
flyctl proxy 5432:5432 -a zootable-na-db &
docker run --rm --network host \
-v $(pwd):$(pwd) \
-w $(pwd) \
-e PGPASSWORD=$PGPASSWORD \
postgres:14-alpine \
pg_dump -Fc -h localhost -U na_zootable zootable > zootable.dump
kill %1
- name: upload the db dump to dropbox
env:
DROPBOX_ACCESS_TOKEN: ${{ secrets.DROPBOX_ACCESS_TOKEN }}
run: |
pip install dropbox python-dotenv
python scripts/uploader.py zootable.dump /zootable.dump