Back up and restore Notary

Notary stores its data in the directory set by db_path in the configuration file. Backup creates a tar.gz archive of that directory. Restore replaces the directory with the contents of an archive.

notary backup and notary restore are separate commands from the running server (notary start). Stop the Notary daemon first so the files on disk are consistent, then run backup or restore, then start the daemon again.

Warning

Do not run backup or restore while the Notary daemon is running. Copying the data directory while dqlite is writing can produce a corrupt archive or a corrupt restore.

Prerequisites

  • Notary installed (snap or a Notary binary)

  • Disk space for the archive, which is roughly the size of the data directory

1. Stop Notary

sudo snap stop notary.notaryd

Stop the notary start process (for example with Ctrl+C, or stop the systemd unit that runs it).

2. Create a backup

The -d / --db-path flag is the data directory (db_path). The -f / --file flag must include a directory path; Notary writes a timestamped archive into that directory (for example backup_20260831_120000.123456789.tar.gz). That directory must be outside db_path, or the backup would include itself.

sudo mkdir -p /var/snap/notary/common/backups
sudo notary backup \
  --db-path /var/snap/notary/common/notary.db \
  --file /var/snap/notary/common/backups/notary.tar.gz
notary backup \
  --db-path /var/lib/notary/database \
  --file /var/backups/notary/notary.tar.gz

The command prints the path of the archive it created.

3. Restore a backup

Restore deletes the current data directory and replaces it with the archive. After restore, cluster.address in the configuration file must still match the node that was backed up.

sudo notary restore \
  --db-path /var/snap/notary/common/notary.db \
  --file /var/snap/notary/common/backups/backup_20260831_120000.tar.gz
notary restore \
  --db-path /var/lib/notary/database \
  --file /var/backups/notary/backup_20260831_120000.tar.gz

4. Start Notary

sudo snap start notary.notaryd
notary start --config /path/to/config.yaml