Prod Backup #177
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: 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 }} |