Reeve Docs

Docs / Operations

Backup and restore

Backup is the infrastructure's job. Reeve has no backup button, no automatic backup and no recovery-point claim; it ships scripts, volume labels and this page. You own the frequency, the retention, the storage and, above all, proving that a restore works. Nothing in the product warns you when no backup has been taken.

What to back up

Thing Verdict Note
PostgreSQL with the TimescaleDB extension Required Holds everything: devices, telemetry and history, automations, scenes, dashboards, accounts and roles, integration metadata, the Data Protection key ring and the audit trail. While object storage stays on the built-in db provider, a database backup is a complete backup
Object storage on a filesystem or S3 provider Required if the active provider is one After a switch, plugin artifacts, plugin-owned objects, installed blueprints and widgets and debug blobs live under the provider's root path or in its bucket, and the database only names that provider as active. Back up the directory or bucket together with the database and restore both: a database restored alone points at objects that are gone. On Compose, a filesystem provider's root path is a volume you add and mount into every backend; the shipped file declares none
Retained workload volumes Required if you use them Matter and Thread fabric material, Bluetooth bind keys, Z-Wave keys. They carry a criticality label so a backup selector can pick them up. Losing bind keys orphans every bonded device; losing a fabric means re-commissioning every ecosystem
The Matter bridge fabric volume Required if you run the bridge See Fabric and credential volumes
Broker retained messages Optional Advisory snapshots. Without them devices take longer to report after a broker restart; the system recovers on its own
Redis No Cache, sessions and queues only. Losing it costs a restart and re-authentication
Installed plugin artifacts No Pulled again at boot from the cluster's object-storage copy or their source; on a filesystem or S3 provider that copy comes back only with the provider's data
Frontend assets No Stateless; they ship in an image

Taking a backup

deploy/scripts/ in the repository holds three scripts: back up, restore, verify.

./deploy/scripts/backup-db.sh [--env-file PATH] [--output PATH]

The backup script reads the database name and user from the deployment's environment file (deploy/.env by default) and the password from deploy/secrets/postgres-password (or the file POSTGRES_PASSWORD_FILE names, or POSTGRES_PASSWORD in the environment), runs a clean-and-create dump inside the database container, compresses it and writes a timestamped .sql.gz (or the path you give, .sql or .sql.gz). Its first line records the database's TimescaleDB extension version (-- timescaledb_version: <version>), which the restore and verification scripts read. It writes to a .partial file and renames it only when the dump finished, so a failed backup never leaves a file that looks complete. Expect tens to hundreds of megabytes compressed, dominated by telemetry history.

The three scripts find the database container of the Compose project named by COMPOSE_PROJECT_NAME (from the environment or the environment file, deploy by default), so a stack started with -p <name> needs COMPOSE_PROJECT_NAME=<name> in its environment file. TIMESCALEDB_CONTAINER names the container directly.

On Kubernetes, prefer a PostgreSQL operator with an object-store backend: automated backups, point-in-time recovery, atomic snapshots without locking live connections, fast parallel recovery. A general cluster-backup tool works too, at the cost of a filesystem copy rather than native streaming. On a single machine, a cron job around the backup script is enough. The three scripts ask for a missing value only on a terminal; run without one, as under cron, the backup and verification scripts stop with an error that names the missing value, so a scheduled backup never waits on a prompt (% is escaped in a crontab):

0 3 * * * cd /opt/reeve && ./deploy/scripts/backup-db.sh --output deploy/backups/reeve-$(date +\%Y\%m\%d).sql.gz

Rotate the files on age. A dump taken with the standard dump tool alone lacks the version line, and one taken without its create option lacks the connection line the restore script needs; take backups with the script.

A workable retention for a typical installation: seven daily backups, four weekly, three monthly. On Kubernetes, add hourly point-in-time recovery and a monthly copy to cold storage. Take a backup before every upgrade, and before any significant change to automations.

Verifying a backup

Do not find out that a backup is corrupt when you need it.

./deploy/scripts/verify-backup.sh --input deploy/backups/<file>.sql.gz [--env-file PATH]

The verification script first reads the whole archive and fails on a corrupt or truncated file (a decompression error, or no completion line at the end of the dump). It then creates a temporary database from template0, restores the archive into it the way the restore script does (TimescaleDB extension at the recorded version, restoring mode around the load) with the connection preamble stripped so the restore cannot reconnect to the live database or change its settings, checks that core.logical_devices and automation.automations can be read and that auth.users and auth.roles have rows (devices and automations may legitimately be empty), then drops the temporary database. When a check fails, the script keeps the temporary database (verify_<time>_<pid>) for investigation and prints the command that drops it. A backup without the version line gets a warning, and its temporary database gets the server's default TimescaleDB version. Run it monthly.

The restore script's dry run reads the archive but loads nothing. restore-db.sh --dry-run reads the whole archive with the same checks as a real restore (corrupt, truncated, or not taken with the backup script) and runs a schema-only dump against the target to check the connection, then refuses, as a real restore would, a backup whose TimescaleDB version the target server does not provide. It does not prove that the archive restores; the verification script does. The dry run's exit codes are 0 (passed), 1 (the backup file is unreadable, truncated or not a backup-script archive, or the target lacks its TimescaleDB version) and 2 (the target database is unreachable, or a tool is missing). Without POSTGRES_USER and POSTGRES_PASSWORD, or without docker, the dry run stops with an error that names what is missing and exits 2, as it does for an unreachable database.

The restore and rollback scripts have opposite defaults. rollback-helm.sh is a dry run unless you pass its live flag; restore-db.sh performs a real restore unless you pass --dry-run. Read the help text before each run.

Restoring

./deploy/scripts/restore-db.sh --input deploy/backups/<file>.sql.gz [--env-file PATH] [--dry-run]

The restore script creates the TimescaleDB extension in the new database at the version the backup records, calls timescaledb_pre_restore() before the archive's objects and data load and timescaledb_post_restore() after them. Without that restoring mode TimescaleDB refuses the hypertable chunks of a plain dump and the restore stops at the first one. Before it changes anything, the script reads the whole archive and refuses a corrupt or truncated one, and checks that the target server offers the recorded TimescaleDB version.

The target server needs the backup's TimescaleDB version. The Compose file pins the image, so a restore onto the same release works. When a release moves the pin to a newer TimescaleDB, the newer image usually still ships the older extension versions, and the restore goes through; then bring the restored database to the image's version with ALTER EXTENSION timescaledb UPDATE; as the first command of a fresh session (docker exec -it <container> psql -X -U <user> -d <database> -c 'ALTER EXTENSION timescaledb UPDATE;'). If the script refuses because the image does not offer that version, restore on the image tag the backup was taken on, switch to the newer image, and run the same update.

The restore replaces the database. The script connects to the postgres database; the archive then drops the database of the backup's name if it exists, creates it again, connects to it and loads into it; when that name is not the environment file's POSTGRES_DB, the script warns. Stop the backend first: a database with open connections cannot be dropped, and the restore stops there with the old database untouched. A restore that aborts after the drop leaves a partial database; running the restore again drops it and starts over.

The backup is taken without owners and privileges, so every restored object belongs to whoever ran the restore. Restore as the application's own role, or reassign ownership afterwards; an object recreated as a superuser can break exactly one query path and leave the rest working.

A backup older than the running binary's schema is brought forward by the boot migration. A backup newer than the binary does not restore into it: there are no downgrade shims.

Total loss

  1. Provision new infrastructure and generate new secrets: signing key and initial administrator password.
  2. Start the database, cache and broker only. Leave the backend down.
  3. Wait for the database to report ready.
  4. Restore the archive. If the active object-storage provider is a filesystem or S3 provider, restore its directory or bucket to the location the provider names too.
  5. Start the backend. It applies any pending migrations, then serves.
  6. Reconnect the clients and confirm that a device command round-trips.

Moving an installation to new hardware

There is no in-app transfer. Move an installation the way you recover from total loss: take a backup, provision the new host and restore it there, with the directory or bucket of a filesystem or S3 object-storage provider at the location the provider names. Restore the Data Protection key table and keep the application discriminator (see Encrypted values and the key ring), or every stored secret becomes unreadable. Carry retained workload volumes over as a snapshot or archive, or adopt them on the new host as in Workload volumes survived, the database did not. Passkeys keep working only when the new host serves the same relying-party identifier, the same domain.

Workload volumes survived, the database did not

A fresh installation writes a new installation identifier, so it never matches the labels on the retained volumes. Use the adopt-from-a-previous-installation path in the deploy wizard: it lists volumes carrying a foreign installation identifier, verifies the ownership evidence (labels, image reference, volume binding) before any forced write, relabels the claim into the current installation and binds it to the new instance. It refuses a volume that is not present, lets only one instance claim a given retained name, and needs workloads.approve.

Where the orchestrator is unavailable, the manual provider is the fallback: install the plugin, select the manual provider, set the externally reachable gateway address, render the artifacts and run them by hand with the retained data mounted at the workload's mount path. The named-volume scheme stays the same, so the volume can be adopted back by label later.

A restored database with workloads mid-update

Boot resumes open update intents before drift reconciliation and tests each for resumability: is the previous image digest still pullable, can the old specification still be rendered from the restored manifest. Resumable ones converge on their own. Non-resumable ones park in a terminal rollback-failed state for a person: retry once the digest is available, or force forward and accept the newer running specification. Both need workloads.approve.

Fabric and credential volumes

The Matter bridge's fabric storage lives on its own volume, keyed by a deployment-stable node identifier. There is no in-app export: recovery is a volume snapshot or a volume archive, and losing the volume means re-commissioning every ecosystem. Credential writes are flushed synchronously when commissioning completes, so a hard kill immediately afterwards still leaves the fabric intact. At start the bridge deletes controller entries left for a fabric that no longer exists and logs each one.

Encrypted values and the key ring

Every value encrypted with ASP.NET Data Protection is bound to the key ring in PostgreSQL's integration.data_protection_keys table and to the application's Data Protection discriminator, which defaults to the content root. That covers plugin configuration secrets, automation trigger secrets, repository credentials, plugin OAuth tokens, encrypted integration and runtime settings, and workload password parameters (stored as enc:v1: values). Back up the database and restore the key table with those rows. A table-level restore that omits the key table, or rows moved to an installation with another discriminator, makes the encrypted values unreadable: restore the matching key rows and the application identity together, or enter the affected credentials again. With a KEK configured, the key ring is wrapped and the KEK is needed too; see Secrets.

  • Saving an automation is refused while one of its trigger secrets cannot be decrypted. Enter that trigger's secret again, then save.
  • A plugin instance whose secret cannot be decrypted does not start and raises the plugin.secret_unreadable alert, which names the field. Enter the secret again and save: in the instance settings for a schema field, or through the instance's options flow for a field only a flow recorded (the settings form shows schema fields only). Or restore the matching key ring.

Sharing workflows and automations

To copy workflows to another installation, export a workflow, or several together as a bundle, and import it there; device and room references are remapped on import (see Automation and workflows). To share an automation pattern, publish it as a blueprint. Neither is a backup: no devices, telemetry, accounts or audit history travel with them.

Schema surgery

The schema is created by a single initial migration, and its down operation drops everything, so a schema rollback is never a downgrade command: it is a restore from backup or a hand-written procedure that reverses one object.

When a release converts a table, for example into a TimescaleDB hypertable, reversing it means, in dependency order: drop the foreign key, decompress every chunk, de-register the table from TimescaleDB, drop the composite key and restore the original one, reverse the index rename, reverse the table rename, restore the original foreign key. Before any of it: scale the backend to zero, take a fresh backup, confirm the extension is present, confirm nothing is in flight.

Leave the migration ledger alone during such surgery. It holds the rows that describe the schema; deleting them makes the next boot rebuild every table from scratch. The database stays knowingly out of step with the model until the object is converted back; that is the intended state, not a fault. If a step fails partway, do not run single steps again from a partial state: restore from the pre-flight backup.

Erasing one subject

Audit entries have no erasure surface in the product: export the subject's rows, then delete by user identifier in the database. Retention is a bulk delete on a regular indexed table, so it shows up as write load and table bloat rather than an instant chunk drop: reindex and vacuum afterwards, and shorten retention to what you need (History and retention).