SafeGrd / Coolify backup

How to back up and restore databases in Coolify

Updated 18 October 2026 ยท labels from Coolify v4's documentation

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

  1. Open the database resource and go to Backups, then + Add.
  2. Set the frequency: daily, hourly, weekly or a cron expression such as 0 3 * * *. It runs in the server's timezone.
  3. 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.
  4. 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.
  5. Set retention: Backups to keep, Days to keep or Maximum storage (GB). 0 means no limit. Local and S3 retention are separate.
  6. Timeout defaults to one hour (3600 seconds). A dump that runs longer fails, so raise it for a large database.
  7. 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

  1. Stop the application's writes, and take one more backup of the target database first. An import can overwrite data and credentials.
  2. On the running database, open Import Backup.
  3. 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).
  4. 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.
  5. 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.

What lives on a Coolify server and which backup holds it. The app's databases go in the scheduled database backup from step 2, uploaded to S3. Coolify's own projects, environment variables and saved secrets go in the instance backup from step 4, which needs the APP_KEY to decrypt. The app's volumes, such as uploads, are in neither. Your Coolify server app database Postgres, MySQL, ... Coolify itself projects, env, secrets app volumes uploads, files database backup step 2, to S3 instance backup step 4, needs APP_KEY no backup not covered
Three kinds of data on one server, and two backups. Keep the APP_KEY somewhere other than the server, or the instance backup cannot be decrypted.

What Coolify's backups leave to you

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.

FeatureSafeGrdCoolify backups
Scheduled backups to S3-compatible storageYesYes
Encrypted on the server before uploadYesNo
Backups written under Object LockYesNo
Scheduled restore tests, with row counts checkedYesNo
Application volumes (uploads)YesNo
Daily, weekly and monthly copies kept longerYesCount, age and size limits
Alerts when a backup fails or runs lateYesNotifications
Restoresafegrd restore on any hostFrom the dashboard
ClickHouseNoYes

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.

  1. Install SafeGrd on the server. Either run the install script over SSH, or run the ghcr.io/safegrd/cli image, which carries pg_dump 18, the MariaDB client, the MongoDB tools and a PostgreSQL server for sandbox drills.
  2. 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.
  3. 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.
  4. 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.

Related