Backing up and recovering FlowAssembly¶
FlowAssembly keeps everything that matters in four places: its database, the files people add to cases, its secrets, and its settings. This guide says how to back each one up, how to restore them within the 60-minute target, and how to check the instance is whole afterwards.
What to back up¶
What |
Where it is |
How to back it up |
|---|---|---|
The database |
Your PostgreSQL |
Continuously, so it can be restored to any moment: base backups and an archive of the write-ahead log, or your managed service’s point-in-time restore. This holds cases, tasks, history, the audit trail, people, settings made in the browser, releases and the trust each environment holds. |
Case files |
A volume ( |
Volume snapshots, or versioning on the bucket. Files are encrypted by FlowAssembly, so the copies are too. |
Secrets |
The secrets file, or Vault or OpenBao |
Securely, apart from the other backups. Without the files key, no case file can be read again. The session key, database password and connection secrets are here too. |
Settings |
|
In version control (your Kubernetes overlay), like the rest of your configuration. |
Back the case files up at least as often as the database, and keep each copy at least as new as the moment you would restore the database to. Then every file the restored database names is there. A file added after that moment is harmless: nothing refers to it.
How much can be lost¶
Server failure. A highly available PostgreSQL with a synchronous standby loses no committed work when the primary fails. That is how FlowAssembly meets “no loss of committed case data”. Use one in production.
Disaster or mistake. Restoring a backup loses whatever was done after the moment restored to. With the write-ahead log archived at least every minute (
archive_timeout = 60on your own PostgreSQL), that is at most about a minute of work before the last archived moment.
Restoring, within 60 minutes¶
Each step has a time it should fit in. Practise them, so the 60 minutes hold when it counts.
Decide the moment to restore to (10 minutes). After a mistake, just before it; after losing the database, the latest. Tell people FlowAssembly is unavailable.
Stop FlowAssembly (2 minutes), so nothing writes while you restore:
kubectl scale deployment -l app.kubernetes.io/part-of=flowassembly --replicas=0
Restore the database to that moment (20 to 30 minutes, depending on its size and how much log there is to replay). Use your managed service’s point-in-time restore, which usually makes a new server; then set
databasein the instance settings to it. On your own PostgreSQL:restore the latest base backup from before the moment into an empty data directory;
add
restore_command,recovery_target_timeandrecovery_target_action = 'promote', and createrecovery.signal;start it, and wait until it is no longer in recovery.
Restore the case files (5 to 10 minutes) from the copy taken at or after the moment.
Check it (5 minutes). With the settings pointing at the restored database:
fa recovery check --actor <you>
It says how far the database reaches, and checks that:
the database matches this version;
the audit trail’s chain is intact;
the case files are there and open with the files key (a sample of 200, or every one with
--all-files).
It also lists the steps that will run again, and records itself in the audit trail. Put right anything it calls a problem before going on.
Start FlowAssembly (5 minutes): scale the deployments back up. Check Admin > Settings > System info, and have someone open a case and complete a task.
Tell people what was lost: work done after the moment restored to must be done again.
After a restore¶
Steps that run again. A step that was calling another system when the backup was taken runs again.
fa recovery checklists them, by connection, so you can check with those systems that nothing was done twice.Messages from other systems. Messages, webhooks and queue messages received after the moment restored to are not in the database. Ask the systems that sent them to send them again.
The audit trail’s seals. Each sealing pass writes the chain’s newest value to the logs. After restoring to an earlier moment, the logs hold seals newer than the restored chain, and
fa audit verify --headwith one of them reports events removed. That is expected: those events were made after the moment restored to. Check against the newest seal the logs hold from before that moment instead. Therecovery.checkedevent in the audit trail records the restore, with how far the database reaches.
How long it takes¶
At 90 days of 2,000 cases a day (a 4.3 GB database, 3.3 million audit events), on one 6-processor machine:
restoring the database, replaying 6 GB of log, took 2.3 minutes;
fa recovery checktook 3 minutes. It checks the whole audit trail, at about a million events a minute, so it takes longer as the trail grows.
Your times depend on your hardware and how much log there is to replay. Practise to know them.
Practising¶
Practise a restore at least every quarter, on a copy, and time it. FlowAssembly
itself is checked this way on every change (tests/recovery_drill.py):
a base backup is taken, and people work;
the database is deleted, then restored to a moment and checked;
what was done before the moment is there, and what was done after is not;
people carry on.