Skip to content

wycks/Supabase-Database-Actions-Backup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Supabase Database Actions Backup

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

Connecting to Supabase

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).

Features

  • 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.

Updated Versions

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 

Improvements

Better Timestamps:

  • Added dedicated timestamp generation step
  • Timestamps now include hours, minutes, and seconds

Organization + Storage Efficiency:

  • Creates dated folders for each backup
  • Compresses backups into .tar.gz files
  • Removes temporary files after compression

Cleanup:

  • Added automatic cleanup of old backups (keeps last 5)

Better Git Handling:

  • Added fetch-depth: 0 for better Git history
  • Improved commit options for reliability

Error Handling:

  • Uses GitHub's warning annotation for disabled backups

S3 support - Not tested

  • 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

About

Github Actions to backup your DB

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages