Skip to content

Back up and restore

Create a Supermetry database archive and restore it safely with the built-in commands.

Back up the configured PostgreSQL database, then restore the archive into a dedicated Supermetry database when needed.

  1. Install PostgreSQL client tools so pg_dump and pg_restore are available.

  2. For a Linux binary install, create a private backup directory and archive the database.

    Terminal window
    sudo install -d -m 0700 -o supermetry -g supermetry /var/lib/supermetry/backups
    sudo -u supermetry env SUPERMETRY_ENV_FILE=/etc/supermetry/supermetry.env \
    /usr/local/bin/supermetry backup --out /var/lib/supermetry/backups/supermetry-backup.tar.gz

    For Docker, write the archive into the application data volume.

    Terminal window
    cd /opt/supermetry
    docker compose exec supermetry /supermetry backup --out /data/supermetry-backup.tar.gz
  1. To restore a binary install, stop the service and confirm replacement of the target database.

    Terminal window
    sudo systemctl stop supermetry
    sudo -u supermetry env SUPERMETRY_ENV_FILE=/etc/supermetry/supermetry.env \
    /usr/local/bin/supermetry restore /var/lib/supermetry/backups/supermetry-backup.tar.gz --yes
    sudo systemctl start supermetry

    Restore only into Supermetry’s dedicated database. The command replaces its database objects and refuses an archive created by a newer schema.

  2. Check readiness after the restored instance starts.

    Terminal window
    curl -fsS http://127.0.0.1:8787/readyz

What you should see: the backup command prints Backup written to ...; restore prints Restore completed, and readiness returns {"status":"ok"}.