Skip to content

Backups and restore

Sail keeps everything in two places: the Postgres database and the file volume. The backup.sh script that comes with Sail copies both, checks them, and leaves you a folder you can restore from.

Sail keeps running while it backs up. Nobody notices.

WhatWhereBacked up by
Chats, memories, assistants, settingsPostgresbackup.sh
Uploaded and generated filesThe sail-data volumebackup.sh
Your settings.envYou
The secret keysecrets/secret-keyYou, separately

The secret key is left out of backups on purpose. Whoever steals a backup still can’t read the secrets inside it. Keep the key in your password manager or secrets store, away from the backups.

From the folder where Sail is installed:

./backup.sh --out /srv/sail-backups

It makes a folder such as sail-backup-20261025T120000Z with:

  • database.dump: the database;
  • files.tar.gz: every file;
  • manifest.json: when it was made, the Sail and Postgres versions, and the number of files;
  • SHA256SUMS: checksums, so you can tell later that nothing was damaged.

The script checks the dump and the archive before it finishes. A folder still named .partial is incomplete. Never restore from one.

Add a line to the server’s crontab:

15 3 * * * cd /opt/msty-sail && ./backup.sh --out /srv/sail-backups --keep 14

--keep 14 keeps the newest 14 backups and deletes older ones.

Then copy the backups somewhere else, such as object storage in another location, with the tool you already use (rclone, aws s3 cp, or your backup software). A backup on the same disk as Sail doesn’t survive a lost disk.

Sail doesn’t encrypt backups. If they leave the server, store them encrypted.

Restoring replaces everything in Sail with the backup.

  1. Check the backup first. Without --yes, the script only verifies checksums and says what it would replace:

    ./restore.sh /srv/sail-backups/sail-backup-20261025T120000Z
  2. Restore:

    ./restore.sh /srv/sail-backups/sail-backup-20261025T120000Z --yes

It stops Sail, replaces the database and files, starts Sail again, and waits until it’s healthy.

Before you restore:

  • Use the same secret key the backup was made with.
  • Run the same Sail version or newer. A newer Sail updates the restored database when it starts.
  • Run the same Postgres major version or newer than the one in manifest.json.
  • On a new server, start Sail once first, so its containers exist.

A backup you’ve never restored is a hope, not a backup. Every few months, restore last night’s backup on a spare server and sign in. If it works there, it’ll work when you need it.

backup.sh backs up the bundled Postgres only. If you run Sail against your own database service, such as Amazon RDS or Azure Database for PostgreSQL, use that service’s backups for the database. Back up the sail-data volume yourself as well.