Forked from: https://github.com/sesto-dev/supabase-database-backup
Please see the original ^ repo and the video for instructions and features.
Video Guide: https://www.youtube.com/watch?v=TY68pfWps64
GitHub actions use IPv4, Supabase direct connections are IPv6. It's recommended you pay the add-on fee for a direct Supabase connection for IPv4 support. Otherwise use the shared Transaction Spooler for IPv4 (not the Sessions pooler).
- Automatic Daily Backups: Scheduled backups run every day at midnight.
- Role, Schema, and Data Separation: Creates modular backup files for roles, schema, and data.
- Flexible Workflow Control: Enable or disable backups with a simple environment variable.
- GitHub Action Integration: Leverages free and reliable GitHub Actions for automation.
- Easy Database Restoration: Clear steps to restore your database from backups.
The main reason for the fork was to update the dependancies, but then I decided to add some features, namely to only keep the last 5 backups (easy to change) , and compress the backups to save on storage space. See below.
Versions need to be verbose
Modify the amount of backups your store by changing (Line 77)
// +6 keeps the last 5 backups based on datetime list
tail -n +6
- Added dedicated timestamp generation step
- Timestamps now include hours, minutes, and seconds
- Creates dated folders for each backup
- Compresses backups into .tar.gz files
- Removes temporary files after compression
- Added automatic cleanup of old backups (keeps last 5)
- Added fetch-depth: 0 for better Git history
- Improved commit options for reliability
- Uses GitHub's warning annotation for disabled backups
- Commented out by default
- After compression sends backup to S3
- Add your Amazon secret key variables to your GitHub action settings
- You should create a dedicated IAM user for a specific bucket, and adjust the code accordingly