Backup and restore
Hold a backup you have actually restored, not a backup you hope works.
A backup is only a backup when a restore has been tested. The reference deployment ships a backup script and a systemd timer that runs nightly at 02:30 Europe/Stockholm.
What to back up
- The PostgreSQL database, including PostGIS data.
- Uploaded attachments and documents.
- The environment file with secrets, stored separately and encrypted.
- The deployed version and its migration state.
The restore test
- Take a backup.
- Restore it into a scratch database on a different port.
- Start a second instance against the scratch database.
- Log in, open an asset and a work order, and confirm the data is intact.
- Record the date, the version and the person who tested it.
Versioned upgrades
Upgrades move forward through tagged releases. The upgrade script takes a target version, applies migrations and restarts. A published tag is never amended; if a defect is found after release, the fix is the next version.
deploy/backup.sh
deploy/upgrade.sh --to vX.Y.Z
# verify: /api/version reports the new version and the expected schema_migrations count
Never upgrade production without a restore-tested backup taken in the same maintenance window.
Recovery time
Measure how long a restore takes. A backup that restores in nine hours is not a disaster-recovery plan for a plant that runs three shifts.
Restore a backup into a scratch database and log in against it. If you have never done this, you do not yet know that your backups work.
Terms
- RPO
- Recovery point objective: how much data you can afford to lose, expressed in time.
- RTO
- Recovery time objective: how long recovery may take before the business is harmed.
OSMAINT Academy · Administration · Backup and restore · osmaint.org/academy/