Skip to content
This repository has been archived by the owner on Sep 19, 2024. It is now read-only.

Add backup and restore actions to bot #882

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/backup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Database backup

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
schedule:
- cron: '0 0 * * *'

jobs:
run_db_backup:
runs-on: ubuntu-latest
permissions:
contents: write
env:
supabase_db_url: ${{ secrets.SUPABASE_DB_URL }} # Encrypted Supabase DB URL

steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}

- uses: supabase/setup-cli@v1
with:
version: latest

- name: Backup roles
run: supabase db dump --db-url "$supabase_db_url" -f roles.sql --role-only

- name: Backup schema
run: supabase db dump --db-url "$supabase_db_url" -f schema.sql

- name: Backup data
run: supabase db dump --db-url "$supabase_db_url" -f data.sql --data-only --use-copy

- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Database backup
33 changes: 33 additions & 0 deletions .github/workflows/restore.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Database restore

on:
workflow_dispatch:
inputs:
restore-trigger:
description: 'Trigger database restore'
required: false
default: 'manual-restore'

jobs:
restore_db:
runs-on: ubuntu-latest
permissions:
contents: read
env:
supabase_db_url: ${{ secrets.SUPABASE_DB_URL }} # Encrypted Supabase DB URL

steps:
- uses: actions/checkout@v3

- uses: supabase/setup-cli@v1
with:
version: latest

- name: Restore roles
run: supabase db restore --db-url "$supabase_db_url" -f roles.sql --role-only

- name: Restore schema
run: supabase db restore --db-url "$supabase_db_url" -f schema.sql

- name: Restore data
run: supabase db restore --db-url "$supabase_db_url" -f data.sql --data-only
Loading