Backup database #97
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}" >> "$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 ${{ steps.filename.outputs.filename }} | |
- name: Compress backup | |
run: gzip ${{ steps.filename.outputs.filename }} | |
- name: Upload compressed backup as GitHub artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ steps.filename.outputs.filename }}.gz | |
path: ${{ steps.filename.outputs.filename }}.gz |