diff --git a/.github/workflows/backup-db.yml b/.github/workflows/backup-db.yml new file mode 100644 index 000000000..7cce6dc7d --- /dev/null +++ b/.github/workflows/backup-db.yml @@ -0,0 +1,34 @@ +name: Supa-backup + +on: + workflow_dispatch: + schedule: + - cron: "0 0 * * *" + +jobs: + run_db_backup: + runs-on: ubuntu-latest + permissions: + contents: write + env: + supabase_db_url: ${{ secrets.SUPABASE_DB_URL }} + steps: + - uses: actions/checkout@v3 + + - uses: supabase/setup-cli@v1 + with: + version: latest + + - name: Generate timestamp + id: timestamp + run: echo "::set-output name=timestamp::$(date +'%Y%m%d%H%M%S')" + + - name: Backup schema + run: supabase db dump --db-url "$supabase_db_url" -f ${{ steps.timestamp.outputs.timestamp }}_schema.sql + + - name: Backup data + run: supabase db dump --db-url "$supabase_db_url" -f ${{ steps.timestamp.outputs.timestamp }}_data.sql --data-only --use-copy + + - uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: Supabase backup