Backup and restore
All Scalengi data lives in two PostgreSQL databases. Back them up together, store the copies off the server, and test the restore.
What to back up
| Database | Content |
|---|---|
Business database (scalengi) | Organisations, members, roles, catalogues, diagrams and their versions, inventories, feedback, settings. |
Identity database (scalengi_identity) | Accounts, password hashes, sessions and single sign-on settings. |
Back up both, at the same moment: a business database restored without its identity database leaves members without accounts. Also keep, in your secret manager, the passwords and secrets used by the services.
Take a consistent backup
The simplest consistent backup is a logical dump of each database while the Core and the identity service are stopped:
docker compose stop core identity
docker compose exec -T database pg_dump -U scalengi_migrator -d scalengi --format=custom --no-owner --no-privileges > scalengi.dump
docker compose exec -T identity-database pg_dump -U identity_migrator -d scalengi_identity --format=custom --no-owner --no-privileges > scalengi_identity.dump
docker compose start identity coreAdapt the service and role names to your Compose files. On a larger installation, physical PostgreSQL backups with point-in-time recovery avoid stopping the services.
Restore
- Stop the Core and the identity service.
- Restore each dump into an empty database of the same version of Scalengi, with
pg_restoreand the migrator role. - Start the identity service, then the Core, and check their health.
- Sign in and check a few organisations, diagrams and inventories.
A restore brings the data back as it was at the time of the backup, including settings such as the responsibility mode.
Test the restore
A backup that has never been restored is not a guarantee. Regularly, on a separate machine: restore the latest dumps, compare the number of organisations, diagrams and objects, open a few diagrams, and measure how long it took. Do it again whenever you change storage or before a migration.