13 After any restore

Do these in order, with web and the worker off. A restored database revives what was true at the backup: a session or token revoked since then works again, and a user deactivated since then is active again. So nothing serves it until step 1 has run, and the worker comes last, as it sends what the restored data asks for.

  1. End what the rewind brought back. The database has to be up, and web doesn't:

    docker compose run --rm --no-deps worker ./node_modules/.bin/tsx --tsconfig tsconfig.worker.json src/lib/jobs/restore-finish.ts --confirm
    

    First it ends every session, revokes every API and SCIM token, removes every calendar feed and upload link, and writes a restore.finished entry to the audit log. A session issued before this runs can't come back, however many times its user's sessions were ended since the backup, even if you restore the same backup twice. Then it checks the audit chain, compares records with files, and writes restore.files_compared. It changes nothing because of those. It prints what else came back and stays in force (step 4). It exits 1 if the chain or the files need a look, including when a store couldn't be read or records name a store this instance doesn't read. The revoking stands either way. Run it once: run again, it revokes anything issued in between.

  2. Start web where only you can reach it. Leave the bundled Caddy off. web listens on the server's loopback address unless you set WEB_BIND, so reach it through an SSH tunnel: ssh -L 3000:127.0.0.1:3000 <server>. If you set WEB_BIND or run your own proxy, keep that closed for now. Start it on the tunnel's address, for this command only. With your public https address, sign-in cookies are marked secure and its pages and links go to the address that is closed:

    APP_URL=http://localhost:3000 docker compose up -d web
    

    Use your WEB_PORT if you changed it. Step 6 puts the real address back. SSO can't finish here, as your identity provider returns to the public address. Sign in with a password. With SSO-only sign-in on, that takes a break-glass administrator, which is one more reason to keep one: without one, steps 3 and 4 wait until you can open the address to yourself alone.

  3. Check the result.

    docker compose exec -T db sh -c 'psql -U "$POSTGRES_USER" -d "$POSTGRES_DB" -At -F " " -f -' < deploy/counts.sql | sort > counts-restored.txt
    curl -fsS http://127.0.0.1:3000/api/health
    

    Compare the counts with what you expect. Sign in and open some attached files. If SETTINGS_ENCRYPTION_KEY or AUTH_SECRET differs from the original, see "A lost secret". If records name a store that moved since the backup, see "A restore across a storage move".

  4. Redo what the rewind undid, before people return. After an incident, these are the ones that matter. restore:finish doesn't touch them, as it can't tell which you changed since the backup:

    • Leavers, access changes and erasures made since the backup. A leaver's account is active again, with its old password. Check against your identity provider. SCIM can't correct it until it has a new token (below), and a password account never corrects itself.
    • Passwords reset since the backup, including after a compromise. The old password works again.
    • Two-step verification. A reset is undone, and used recovery codes work again.
    • Revoked delegations. They are back, with their rights to approve and sign. The command prints how many are active.
    • Administrator rights, group changes and SSO links changed since the backup.
    • Security settings turned on since the backup, such as SSO-only sign-in, the two-step requirement and AI assistant access, and any integration secret rotated since then.
    • Webhooks removed since the backup. They post again once the worker starts, and report schedules run again. The command prints how many there are.
    • Open assessment links. A questionnaire that expired or was completed since the backup is open again for anyone holding its link, and accepts answers and evidence. They stay working, so vendors filling one in aren't cut off. The command prints how many are open. Expire any that shouldn't be, under the assessment's request.
    • Records made since the backup. Re-enter them from whatever you have.
  5. Issue new credentials. Give every integration a new API token, and your identity provider a new SCIM token. People create new calendar feeds and upload links.

  6. Start the worker and everything else. It settles anything a stopped storage command left. Jobs queued when the backup was taken come back with it, so an email or scheduled report from that moment can go out a second time, and so does any email still marked queued then, up to three days old, or 30 for a security alert. Tell people to expect that. Reminders and sweeps run on their next schedule.

    docker compose --profile tls up -d
    

    Leave out --profile tls if you don't use the bundled Caddy, and open your own proxy now if you closed it.

  7. Record the gap. Audit entries since the backup are gone from this instance, and the chain continues from the restored head with no sign of a gap inside the chain. Compare with the outside record of chain checks the Administrator's Guide advises, keep the restore.finished entry, and write down the backup time, who restored, why, and what was redone, as your own change control requires.