Backup #303
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 | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '0 2 * * *' | |
jobs: | |
backup: | |
runs-on: ubuntu-latest | |
name: Backup DB | |
steps: | |
- name: Checkout contents repo | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.DWARVES_PAT }} | |
submodules: recursive | |
fetch-depth: 5 | |
- name: Install devbox | |
uses: jetpack-io/devbox-install-action@v0.11.0 | |
with: | |
enable-cache: true | |
devbox-version: 0.12.0 | |
- name: Export DB | |
shell: bash | |
run: | | |
git config --global user.email "actions@github.com" | |
git config --global user.name "GitHub Actions" | |
devbox run duckdb-export | |
mkdir backup | |
tar -czvf ./backup/$(date +%Y-%m-%d).tar.gz db | |
env: | |
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | |
INFINITY_API_KEY: ${{ secrets.INFINITY_API_KEY }} | |
INFINITY_OPENAI_BASE_URL: ${{ secrets.INFINITY_OPENAI_BASE_URL }} | |
JINA_API_KEY: ${{ secrets.JINA_API_KEY }} | |
JINA_BASE_URL: ${{ secrets.JINA_BASE_URL }} | |
- name: Upload latest db for querying | |
uses: jakejarvis/s3-sync-action@master | |
with: | |
args: --acl public-read --follow-symlinks --delete | |
env: | |
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }} | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_REGION: ${{ secrets.AWS_REGION }} | |
SOURCE_DIR: db | |
DEST_DIR: db | |
- name: Upload backup to S3 | |
uses: jakejarvis/s3-sync-action@master | |
with: | |
args: --follow-symlinks | |
env: | |
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }} | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_REGION: ${{ secrets.AWS_REGION }} | |
SOURCE_DIR: backup | |
DEST_DIR: db/backup | |