I added a restore test to my Supabase backups. It showed two triggers I'd never backed up.
I kept telling people to test their backups, so it felt a bit hypocritical that I'd never restored mine. A few weeks ago I wrote about opening my Supabase backup for the first time . I counted the rows inside the dump and compared them with the live database. That proved the file wasn't empty. It didn't prove I could actually restore it. So I made the backup workflow restore itself, every week,…
The author added a restore test to their Supabase backups, which revealed two triggers they had previously overlooked. Initially, they only tested their backup by comparing row counts between the dump and the live database, but this did not confirm that the backup could be successfully restored. To address this, they created a workflow that restores the backup weekly into an empty Postgres database.
This process uncovered important details about the Supabase backup format and the need for certain tables and functions to be restored in a specific order. Specifically, the two triggers responsible for creating profiles during user sign-ups were missing from their initial backup. After adding the backup of these trigger definitions, the restore test confirmed that all elements, including tables, functions, triggers, and row counts, matched between the backup and the restored database.
The workflow is designed to run on GitHub Actions, requiring only two secrets for setup, and serves as a free tool for anyone looking to verify their Supabase database backups.
Rewritten by urgent.news; may contain errors — check the original.
Source: dev.to