Backup and restore

A backup of CoverOps is three things, and a backup that is missing any of them restores a product that looks whole and is not:

WhatWhere it livesWhy it matters
The databasethe pg-data volume, or your external Postgresprojects, coverage, traces, day tables, symbols, tokens, audit log
coverops.envthe install directorysecrets: the JWT signing key (losing it logs everyone out), COVEROPS_SECRETS_KEY (losing it makes every stored git token and connector key unreadable), the database password, the bootstrap credentials
Certificates and rclone.confTLS_CERT_DIR, the install directorythe edge's identity and the backup destination's credentials

CoverOps does not use an object store of its own; there is no S3 bucket of artefacts to back up. Object storage enters only as the destination of backups, which is where it belongs. Session replay and UI coverage are read from ReplayOps over its API and are not stored in CoverOps; they are in ReplayOps' backups, not these.

Scheduled backups (the default you should turn on)

# coverops.env
BACKUP_EVERY_HOURS=24
BACKUP_KEEP_DAYS=14
BACKUP_DIR=/srv/coverops-backups        # a different disk from the data volume
RCLONE_CONF=./rclone.conf               # from rclone.conf.example, chmod 600
BACKUP_RCLONE_REMOTE=s3:acme-backups/coverops
docker compose --env-file coverops.env --profile backups up -d

The backup sidecar runs pg_dump (custom format, same Postgres major as the database), writes VERSION and SHA256SUMS, prunes directories older than BACKUP_KEEP_DAYS and, when a remote is set, copies each backup off the host with rclone the moment it is written. rclone speaks S3 and anything S3-compatible (MinIO, Ceph), Azure Blob, Google Cloud Storage, SFTP and SMB; rclone.conf.example has the three common shapes.

A backup on the same disk as the data protects against a bad upgrade and nothing else. Off-host is the backup.

Destination settings worth insisting on: versioning or object lock on the bucket (a deleted backup is then a soft delete), a lifecycle rule that keeps dailies for 30 days and monthlies for a year, and a key that can write and list but not delete: ransomware that reaches the host should not be able to reach the history.

Managed Postgres: do both

With Amazon RDS / Aurora, Azure Database for PostgreSQL or Cloud SQL, turn on the provider's automated backups and point-in-time recovery (7–35 days). That covers the database better than a nightly dump can (recovery to any second). Keep the sidecar running anyway: it is the only thing that backs up the env file, and a pg_dump is what you restore onto a different provider or into a lab. Set POSTGRES_HOST for the sidecar to the managed endpoint.

Manual backup

./backup.sh                 # → ./backups/coverops-<stamp>/
./backup.sh /mnt/usb        # anywhere else

Same contents as the sidecar's. Take one before every upgrade.

Restore

On a fresh install (or the same host after a loss):

./install.sh                # or --offline; brings up the same version if you can
./restore.sh /srv/coverops-backups/coverops-20261004-020000
./doctor.sh

restore.sh refuses to overwrite a database that already has tables unless you pass --force; stops the API and dashboard while it works so nothing writes mid-restore; restores the dump; and warns when the backup came from a different version; then run the migration once:

docker compose --env-file coverops.env up migrate

Restoring the env file is a copy; restoring certificates is a copy to TLS_CERT_DIR. A restore onto a host with a different JWT_SECRET works and signs everyone out once; agent tokens are unaffected (they are hashed in the database, not signed with the key). A restore onto a host with a different COVEROPS_SECRETS_KEY does not: stored git tokens, connector and AI keys stay encrypted under the old key. Put the old key in COVEROPS_SECRETS_PREVIOUS_KEYS (or restore the env file too), then run reseal-secrets.mjs to move them onto the new one.

The dump holds third-party credentials only in encrypted form, so a dump on its own does not reveal them. backup.sh writes the env file next to the dump, which keeps a restore one step; if your off-host copies go somewhere less trusted than the install directory, keep COVEROPS_SECRETS_KEY in your secret store instead and leave it out of that copy.

From an off-host copy, pull the directory back first:

rclone --config rclone.conf copy s3:acme-backups/coverops/coverops-20261004-020000 ./restore-src
./restore.sh ./restore-src --force

Recovery objectives, honestly

SetupRPO (data you can lose)RTO (time to be back)
Bundled Postgres, daily sidecar, off-host copyup to 24 h (shorten with BACKUP_EVERY_HOURS=6)20–40 minutes on a prepared host: install, pull back, restore
Managed Postgres with PITR + sidecar for the restseconds for the database; the env file changes rarelyprovider restore (10–30 min) + install
Air-gapped, backups to a second disk + periodic exportthe export intervalas above, plus getting the host back

Coverage and traces keep arriving while you restore; agents buffer briefly and retry, so a short outage loses little. What is lost between the backup and the failure is traffic data, not configuration.

The drill

A backup nobody has restored is a hypothesis. Quarterly, on a scratch VM: install the current version, restore last night's backup, run ./doctor.sh, open the dashboard, pick a project from before the backup and confirm its coverage map opens. Record date, backup used, and minutes taken; that record is the evidence a SOC 2 reviewer asks for under availability (A1.2), and the day you need it for real you will be glad the steps are muscle memory.

What is not in a backup

The images. VERSION records which ones you need; your registry (or the bundle archive) is where they come from. On a host that cannot reach a registry, keep the bundle beside the backups.