Skip to content

Backup database

Backup database #2

Workflow file for this run

name: Backup database
on:
workflow_dispatch:
schedule:
- cron: '0 11 * * *'
env:
FLY_APP_NAME: feedyouremail
jobs:
backup-db:
name: Backup DB
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Generate backup filename
id: filename
run: |
CURRENT_DATE=$(date +"%Y-%m-%d_%H-%M-%S")
echo "filename=backup_${CURRENT_DATE}.gz" >> "$GITHUB_OUTPUT"
- name: Setup Fly.io CLI
uses: superfly/flyctl-actions/setup-flyctl@master
- name: Fetch backup from Fly.io
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
run: |
flyctl -a ${{ env.FLY_APP_NAME }} ssh sftp get /rails/storage/production/backup.sqlite3.gzip ${{ steps.filename.outputs.filename }}
- name: Upload compressed backup as GitHub artifact
uses: actions/upload-artifact@v4
with:
name: ${{ steps.filename.outputs.filename }}
path: ${{ steps.filename.outputs.filename }}