Know when Coolify's database backups stop working
One Coolify user found their uploads to Cloudflare R2 had stopped “about two weeks ago or so (yeah, it took me this long to notice)”. Another sees about 4% of hourly uploads to Backblaze B2 fail while the job reports “succeeded with a warning” and Validate connection stays green. A scheduled backup can stop, or upload something that does not restore, and look fine in the dashboard. This guide checks the backups Coolify already makes, first with a script, then with SafeGrd.
1. What to check
| Check | Catches |
|---|---|
| The newest backup is younger than its schedule allows | Uploads that stopped: a changed key, a full bucket, a server that was rebuilt without its schedule. |
| It is about as large as the last one | A dump cut short in the upload, or a database that lost most of its rows before the backup. |
| It restores, and its tables hold rows | A file that is not a dump at all, or one pg_restore refuses. |
Opening the file is not a check. Here is a 4.6 MB dump cut to its first 2 MB, as an
interrupted upload leaves it. pg_restore -l reads the table of contents at the
start of the file and exits 0. The restore stops where the rows run out:
$ head -c 2000000 pg-dump-app-1793458215-1.dmp > check.dmp
$ ls -l *.dmp
-rw-r--r-- 1 root root 2000000 Oct 31 14:50 check.dmp
-rw-r--r-- 1 root root 4633367 Oct 31 14:50 pg-dump-app-1793458215-1.dmp
$ pg_restore -l check.dmp > /dev/null; echo $?
0
$ pg_restore -U postgres --single-transaction --exit-on-error --no-owner --no-acl -d restore_check check.dmp; echo $?
pg_restore: error: could not read from input file: end of file
1
postgres:17, with a 200,000-row users table dumped by pg_dump --format=custom, the format Coolify uses.
Coolify writes PostgreSQL backups with pg_dump --format=custom, named
pg-dump-DATABASE-UNIXTIME-ID.dmp, under
data/coolify/backups/databases/TEAM/DIRECTORY/ in the bucket, and the same path
on the server when S3 is off. MySQL and MariaDB backups are plain mysqldump SQL
(mysql-dump-DATABASE-UNIXTIME-ID.dmp, mariadb-dump-…), and MongoDB
backups are one gzipped mongodump --archive
(mongo-dump-DATABASE-UNIXTIME-ID.tar.gz, a tar in name only).
2. With a script
Run it from cron on a machine other than the Coolify server, once a day for a daily backup.
The age limit is 26 hours. The last line pings a Healthchecks.io check, which alerts you when
the script fails or stops running. date -d is GNU's; on macOS use
gdate. Compare the size by hand, or keep yesterday's from aws s3 ls
in a file. Run pg_restore from the same PostgreSQL major as the database, or a
newer one.
3. With SafeGrd
With no host at all: in the console, Back up on SafeGrd, pick the engine, tick Check the backups another tool makes, and give the bucket, the prefix and a key that can only list and read it. SafeGrd holds the key encrypted and runs the checks and drills below on machines it starts. Or add the location as a surface on any host with the SafeGrd daemon, with the same key:
- Every day the daemon reads the newest backup once and counts each table's rows. When Coolify writes nothing for two days, the surface is Overdue and you get an alert.
- Threat Shield compares each backup's rows and size with the last, and warns on a drop. A dump that does not open, or ends early, is a failed backup.
- Fire Drills load the backup into a throwaway database and compare every table with the count. The certificate says Coolify made the backup.
- The key stays on your host, and nothing Coolify wrote passes through SafeGrd's server.
- A MySQL, MariaDB or MongoDB backup is checked the same way, with
type: mysqlortype: mongodbon the surface. Each surface reads only its own engine's files under the tree.
This proves the backup restores. It does not prove the dump holds every row, because SafeGrd never reads the database itself. For that, let SafeGrd take its own backups too (Coolify backup). The details are on the PostgreSQL page, and on the MySQL and MongoDB pages.