Backup and restore
Know which data to back up, run the backup and restore scripts, and roll back a release safely.
What holds data
| Data | Where | Backed up by |
|---|---|---|
| Entities, dashboards, widgets, rule chains, alarms, telemetry, images and JS resources, users | PostgreSQL (nexus_postgres-data) | backup.sh (pg_dump -Fc) |
nexus-services tables (schema nexus_water: reports, schedules, scenes metadata, billing …) | PostgreSQL | backup.sh (same dump) |
| Scene GLB models and images, report files, file-drop inbox, catalogue workspace (drafts, published items, install counts) | nexus_services-data volume | backup.sh (services-data tar) |
| Install marker, class-data archive | nexus_backend-data volume | backup.sh (backend-data tar, small; without the class-data archive) |
| Backend server logs | nexus_backend-logs volume | backup.sh (backend-logs tar; BACKUP_INCLUDE_LOGS=false leaves it out; restore.sh --with-logs puts it back) |
Kafka queue data (only with TB_QUEUE_TYPE=kafka) | nexus_kafka-data | Not backed up: transient messages |
| Configuration and secrets | deploy/production/.env, TLS certificates | Your own secure copy (never in the repository) |
| Reusable content (dashboards, widgets … as packages) | Repository Database/ | Git |
Back up
deploy/production/backup.sh # production (reads deploy/production/.env)
deploy/production/backup.sh --local # the local docker-local stack
Each run writes into BACKUP_DIR (default /var/backups/nexus) a folder nexus-<timestamp>/ with: postgres.dump, services-data.tar.gz, backend-data.tar.gz, backend-logs.tar.gz and manifest.txt (SHA-256 of each file, image versions, git commit). A stopped service's volume is read with a throw-away container of its image, so a backup is complete even while nexus-services or the backend is down. The dump is checked with pg_restore --list and the archives with tar -t before the run counts as good. Old runs are removed after BACKUP_KEEP_DAYS (14). BACKUP_OFFSITE_CMD copies each run elsewhere. Schedule it daily (deploy/production/README.md has a cron line and a systemd timer).
A content export complements the backup: python3 -I Database/tools/nexus_content.py export --out <dir> gives readable JSON of dashboards, rule chains and profiles, useful to compare or to rebuild single items.
Restore
deploy/production/restore.sh /var/backups/nexus/nexus-20261103-020000 # production
deploy/production/restore.sh --local <backup folder> # local stack
deploy/production/restore.sh --check <backup folder> # verify only, change nothing
restore.sh checks the manifest checksums first, then stops the backend and nexus-services, keeps a safety dump of the current database, restores the database (pg_restore --clean --if-exists), replaces the contents of the services and backend data volumes from the archives, and starts the services again. It never deletes a Docker volume. Run a restore drill on a test machine at least once per quarter: restore the latest backup and log in.
Rollback of a release
Production keeps each release in /opt/nexus/releases/<commit>; images are tagged by commit. Roll back by re-running the deploy of the previous commit (GitHub Actions "Deploy to EC2", input ref). If the newer release migrated the database schema, restore the backup taken before the deploy (deploy.sh takes one automatically unless --no-backup).