-
-
Notifications
You must be signed in to change notification settings - Fork 1
35 lines (32 loc) · 1.06 KB
/
db-backup.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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