How to back up and restore databases in Coolify
Open the database in Coolify, go to Backups, add a schedule, and turn on S3 storage so the dumps leave the server. To restore, use Import Backup on a running database. Coolify backs up PostgreSQL, MySQL, MariaDB, MongoDB, ClickHouse and SQLite; Redis, Dragonfly and KeyDB need the engine's own persistence.
Two things the scheduled backup does not do: test that the dump restores, and back up Coolify itself (your projects, settings and saved credentials). Both are covered below.
1. Add S3-compatible storage
A backup on the same server as the database is lost with the server. Before anything else, give Coolify a bucket somewhere else: in the sidebar, S3 Storages, then + Add, with the endpoint, bucket, region, access key and secret key from your provider. Coolify checks the connection before it saves.
Use a key that can write to that one bucket and nothing more. If your provider supports S3 Object Lock, turn it on for the bucket: then even a stolen Coolify login cannot delete the copies before they expire (Immutable backups with S3 Object Lock).
2. Schedule the backup
- Open the database resource and go to Backups, then + Add.
- Set the frequency:
daily,hourly,weeklyor a cron expression such as0 3 * * *. It runs in the server's timezone. - Under Database selection, pick All databases or name them in Databases to back up. With the default, only one database may be dumped. If your app uses a second database, it is easy to miss.
- Under S3 storage, tick Enable S3 and choose the storage from step 1. Delete after S3 upload frees the server's disk; leave Local copy on if you want a quick restore from the server.
- Set retention: Backups to keep, Days to keep or Maximum storage
(GB).
0means no limit. Local and S3 retention are separate. - Timeout defaults to one hour (3600 seconds). A dump that runs longer fails, so raise it for a large database.
- Click Back up now and open Executions. Check that the run succeeded and that the file is in the bucket.
Local copies are written under /data/coolify/backups on the server. Coolify skips a
scheduled run while the database is stopped, starting or importing, so a database that was down
at 03:00 has no backup for that day.
3. Restore a backup
- Stop the application's writes, and take one more backup of the target database first. An import can overwrite data and credentials.
- On the running database, open Import Backup.
- Pick the source: upload a file from your computer, give the absolute path of a file on the server and click Check file, or choose your S3 storage and enter the file's path inside the bucket (the object key, without the bucket name).
- Choose the options. For PostgreSQL, Replace objects that already exist is off by default, so a restore over an existing schema reports an error for each object that is already there. For MongoDB the equivalent is Replace collections that already exist.
- Start the restore, confirm, and follow Database Restore Output to the end.
Then check it. Coolify's own docs say it plainly: a successful backup only proves that Coolify created a file. Open a terminal on the database and count something you know: the rows in your largest table, the newest order. Better still, restore into a new, empty database resource rather than the live one, compare, and delete it. Do that monthly. How to test that a backup restores has the queries.
4. Back up Coolify itself
The database backups above hold your app's data. They do not hold Coolify's own: projects,
resources, environment variables, saved credentials and deployment history. Set up an instance
backup under Settings, Backup (the first time, Configure backup), and
restoring it on a new server needs one more thing: the APP_KEY from
/data/coolify/source/.env. Without it, the saved secrets in the backup cannot be
decrypted. Copy that value into your password manager today.
APP_KEY somewhere other than the server, or the instance backup cannot be decrypted.What Coolify's backups leave to you
- Restore tests. Schedule a monthly restore into a scratch database and compare row counts.
- Encryption before upload. Coolify's docs describe no encryption of the dump itself, so anyone with read access to the bucket can read your data.
- Deletion protection. Coolify's retention, or anyone with the server or the bucket key, can delete old backups. Object Lock on the bucket fixes that.
- Volumes. Uploads and other files in an application's volumes are not database backups and are not covered.
Check the backups Coolify already makes
To keep Coolify's backups as they are, point SafeGrd at the bucket or directory Coolify writes them to. It alerts when Coolify stops writing, compares each backup's rows and size with the last, and on a schedule restores the newest into a throwaway database and counts every table. The key it needs can only list and read. How to set it up, with a script that does the same without SafeGrd.
Adding SafeGrd on the same server
SafeGrd covers those four. It runs next to Coolify, encrypts each backup on the server before upload, writes it under S3 Object Lock, and on a schedule restores the newest one into a throwaway database and checks every table's row count against the backup's manifest.
| Feature | SafeGrd | Coolify backups |
|---|---|---|
| Scheduled backups to S3-compatible storage | Yes | Yes |
| Encrypted on the server before upload | Yes | No |
| Backups written under Object Lock | Yes | No |
| Scheduled restore tests, with row counts checked | Yes | No |
| Application volumes (uploads) | Yes | No |
| Daily, weekly and monthly copies kept longer | Yes | Count, age and size limits |
| Alerts when a backup fails or runs late | Yes | Notifications |
| Restore | safegrd restore on any host | From the dashboard |
| ClickHouse | No | Yes |
Running both works well: Coolify's backups give a one-click restore from its dashboard, and SafeGrd keeps a locked, tested copy that someone with access to the Coolify server cannot delete early.
- Install SafeGrd on the server. Either run the install script over SSH, or
run the
ghcr.io/safegrd/cliimage, which carriespg_dump18, the MariaDB client, the MongoDB tools and a PostgreSQL server for sandbox drills. - Give it a path to the database. A container on the same Docker network as the database uses the internal URL Coolify shows on the database's page. The install script on the host needs the database's port published to the server.
- Add the database as a surface in the SafeGrd console, with a read-only role, and pick a bucket that supports Object Lock or SafeGrd's hosted storage.
- Let the drills run. The daemon restores the newest backup into a throwaway database on the server, checks it, and signs the result.
docker run --rm -it -v safegrd:/home/safegrd/.safegrd ghcr.io/safegrd/cli enroll
To restore, create an empty database and point the restore at it. The same command takes a
mysql://, mariadb:// or mongodb:// URL, and
--target-dir for a directory such as an uploads volume. It refuses a database that
already holds tables, so it never writes over data.
safegrd restore --snapshot SNAPSHOT_ID --target "postgres://user:pass@host:5432/recovered"
Run your first Fire Drill Read the install guide
Questions
Which Coolify databases does SafeGrd cover?
PostgreSQL, MySQL, MariaDB and MongoDB, and SQLite files on the server. It also backs up directories, such as an application's uploads volume, and IMAP mailboxes under the same key.
What happens to the backups if the server is lost?
They are in the bucket, not on the server. With a SafeGrd-managed key, SafeGrd keeps your key sealed and releases it only to your enrolled hosts, so you can restore even after losing a host. With a customer-managed key, only you can decrypt these backups, so keep a copy of the key file somewhere off the server.
Does the drill load the production database?
The drill reads from storage, not from the database, and restores into a separate throwaway database. The only load on the production database is the backup itself, which reads it once.
Coolify details from its documentation (Backups, Restore a Database, Restore Coolify), read on 12 October 2026. Labels can move between Coolify releases.