Backup and restore
A backup is a copy of data kept apart from the system that uses it, so that the data can be brought back after a deletion, a hardware or software failure, an attack or a disaster.1 Loading that copy into a working system is a restore. A backup job can fail without anyone noticing, and a copy that has never been restored is untested: in 2017 GitLab found its database backup bucket empty at the moment it needed a restore.2 Recovery tests on a schedule, run alongside the regular backups, confirm that the copies are intact.1
Recovery objectives
A recovery plan is measured against two figures. The recovery point objective (RPO) is the point in time to which data must be recovered after an outage.3 The recovery time objective (RTO) is how long the system can stay in recovery before the outage harms the work it supports.4
The interval between copies sets the RPO. A Supabase project with daily backups can still lose a day of changes; the point-in-time recovery add-on uploads the database change log every two minutes, which gives a worst-case RPO of two minutes.5 The RTO depends on the size of the data and the speed of the storage: a Supabase project cannot be reached while it is being restored, and the downtime grows with the size of the database.5
Kinds of copies
A logical backup stores the data as commands that rebuild it. The Postgres tool pg_dump writes a file of SQL statements that recreate the database as it was when the dump started; the dump is internally consistent and does not block other work on the database, apart from operations that need an exclusive lock, such as most ALTER TABLE statements. Its output can generally be loaded into a newer Postgres version, while file-level copies are tied to the server version that made them.6 pg_dump covers one database and leaves out roles; pg_dumpall --globals-only saves the roles and other cluster-wide settings.6
Copying the database's files on disk gives a physical backup instead. Combined with an archive of the write-ahead log, which records every change the database makes, it allows a restore to any moment inside the retention window: the restore loads the last physical copy and then replays the logged changes up to the chosen time.5
On a cloud server, a server backup or snapshot copies the whole virtual disk. Hetzner Cloud takes server backups once a day and keeps seven, deleting the oldest when a new one is made; neither backups nor snapshots include volumes attached to the server.7 Replication to a second database server is a separate mechanism. GitLab used it for failover, and when data was removed from the primary, the standby offered no way back.2
Where copies are kept
The 3-2-1 rule asks for three copies of important data, on two different types of storage, with one copy kept off-site.1 Many Ransomware and data destruction variants search for reachable backups and delete or encrypt them, so backups should be kept offline and encrypted.8 Storage that attackers target can get delete protection or object lock, and versioning keeps the earlier versions of stored objects after an overwrite.8
Backups kept by the hosting provider are tied to the account that holds them, and deleting a Supabase project removes its backups as well. Supabase makes daily backups for projects on the Pro, Team and Enterprise plans; a free project should export its data with the CLI db dump command and keep the files off-site.5 A backup holds the data it protects, so a copy left where the public can reach it becomes a leak (see Exposed backups).
Testing a restore
A restore test should show that data can be restored both in full and in part, and rolled back at least seven days.1 It loads the newest copy into a separate database, never over the live one; a Supabase point-in-time restore goes to a new project first for the same reason.5 For a Postgres dump in the custom format:
pg_dump -Fc dbname > filename
createdb -T template0 restore_test
pg_restore -d restore_test filenameRoles that own tables or hold grants must exist before the restore, or ownership and permissions are not recreated. A plain SQL dump loaded with psql keeps going after an error and leaves a partial database unless it is run with --set ON_ERROR_STOP=on or --single-transaction.6
Some data sits outside the database copy. Supabase database backups hold only the metadata of files uploaded through Storage, not the files, and daily backups leave out the passwords of custom roles, which must be reset after a restore.5
Notable incident
On 31 January 2017 an engineer at GitLab, trying to repair database replication, wiped the Postgres data directory on the primary server instead of the standby; around 300 GB was gone before the command was stopped. The daily pg_dump job had been failing: it ran pg_dump 9.2 against a 9.6 database, which ends in an error, and the cron failure emails were rejected because DMARC was not set up for them. Disk snapshots were not enabled on the database servers.2
GitLab restored from a snapshot an engineer had taken by hand about six hours earlier. Copying it from the staging environment took around 18 hours over throttled network disks, and GitLab.com was down for about 18 hours. Database changes made between 17:20 and 00:00 UTC were lost, affecting an estimated 5,000 projects, 5,000 comments and 700 new user accounts; Git repositories were not affected. The postmortem traced the untested backups to missing ownership, and the follow-up work included automated testing of database backup restores and an owner for data durability.2
In SecFlash
On the Cloud page, SecFlash reports a Hetzner server with backups switched off as SF-CLD-104, a Hetzner volume that no backup covers as SF-CLD-105, a DigitalOcean Droplet with backups off as SF-CLD-205, and a Supabase project with point-in-time recovery off and no finished backup from the last two days as SF-CLD-525.
See also
- Ransomware and data destruction
- Exposed backups
- Responding to a database exposed to the internet
- Encryption at rest
- Securing a Docker application on a self-managed server
- Category: Security concepts
References
- a b c d CISA. "Back Up Business Data". Cybersecurity and Infrastructure Security Agency.
- a b c d GitLab (10 February 2017). "Postmortem of database outage of January 31". GitLab blog.
- back NIST. "Recovery point objective", from NIST SP 800-34 Rev. 1. CSRC Glossary.
- back NIST. "Recovery time objective", from NIST SP 800-34 Rev. 1. CSRC Glossary.
- a b c d e f Supabase. "Database Backups". Supabase documentation. Updated 12 November 2026.
- a b c PostgreSQL Global Development Group. "25.1. SQL Dump". PostgreSQL 19 documentation.
- back Hetzner. "Backups/Snapshots". Hetzner Docs.
- a b CISA, MS-ISAC, NSA and FBI (September 2023). "#StopRansomware Guide". Cybersecurity and Infrastructure Security Agency.
External links
- Backup and Restore, PostgreSQL documentation