A lightweight Python script to back up your Supabase Postgres database—one-time or on a recurring schedule.
- Python 3.8+
- pg_dump (PostgreSQL client tool)
- pip (Python package installer)
- A Supabase Project
Clone this repo and run the setup script:
git clone https://github.com/DuncBoi/SupabaseBackupScript.git
cd SupabaseBackupScript
bash setup.shActivate your environment and run the backup script:
source .venv/bin/activate
python supabase_backup.pyThe script will guide you:
- Where to get your Supabase "Transaction Pooler" database URL
- Where to save the backup
- How to schedule recurring backups
- How to overwrite or keep separate backups
If you choose to schedule, the script will generate a cron job for you and explain how to use/remove it. You can view or edit scheduled jobs at any time:
crontab -eTo remove the scheduled backup, simply delete the backup line from your crontab file.
To remove your virtual environment and backup files:
deactivate # (if you're in the venv)
rm -rf .venv supabase_backup_*.dump-
Make sure
pg_dumpis installed and in your PATH.- On macOS:
brew install postgresql - On Ubuntu/Debian:
sudo apt-get install postgresql-client - On Windows: Install from postgresql.org
- On macOS:
-
If you get connection errors, double-check your Supabase database URL and password.
-
If cron jobs don't run as expected, make sure your machine is on and not asleep at the scheduled time.
Built with rich for terminal UI.
Author: Duncan Greene