-
Notifications
You must be signed in to change notification settings - Fork 0
43 lines (36 loc) · 1.25 KB
/
prod-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
36
37
38
39
40
41
42
43
name: Prod Backup
on:
schedule:
- cron: '0 0 * * *'
jobs:
backup:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- uses: superfly/flyctl-actions/setup-flyctl@master
- name: Get current date
id: date
run: echo "::set-output name=date::$(date +'%Y-%m-%d')"
- name: Copy db file from server
# note: CURL the API first to wake up the server
run: |
mkdir ./backup
curl https://api.biscuits.club
flyctl ssh sftp get /data/storage.sqlite ./backup/storage.sqlite
flyctl ssh sftp get /data/database.sqlite ./backup/database.sqlite
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
FLY_APP_NAME: biscuits-club
- name: Upload to S3 in directory by date
uses: jakejarvis/s3-sync-action@master
with:
args: --follow-symlinks
env:
AWS_S3_BUCKET: ${{ secrets.S3_BUCKET_BACKUPS }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: us-east-1
SOURCE_DIR: ./backup
# date string
DEST_DIR: ${{ steps.date.outputs.date }}