Sub topic 15
Practicing a full recovery
Assume you are comfortable with the Linux command line, SSH, file permissions, systemd, and the basic layout of /etc, /home, and /var. This chapter uses the repository and backup commands from earlier chapters. A recovery drill tests the complete path from stored backup to working service. A successful backup alone does not prove that recovery will work.
Define the recovery target
Write down what the recovered server must provide:
- The recovery point objective (RPO) is the maximum acceptable data loss. If the RPO is 24 hours, a daily backup may be sufficient.
- The recovery time objective (RTO) is the maximum acceptable time until service is available.
- The recovery target is a separate virtual machine, physical machine, or temporary directory. Do not begin by overwriting the production server.
A full recovery usually includes these stages:
Use a recent backup for a routine drill. Also test an older backup occasionally, because retention and key management failures can affect older recovery points.
Restore without damaging production
First inspect the available recovery points. For restic, select a snapshot by time, hostname, or ID:
export RESTIC_REPOSITORY=sftp:[email protected]:/srv/restic/myserver
export RESTIC_PASSWORD_FILE=/etc/restic/password
restic snapshots
restic ls latest /etc/nginx /var/wwwRestore into a temporary directory. The --target option places the restored absolute paths below that directory, so /etc/nginx becomes /tmp/recovery/etc/nginx.
sudo install -d -m 700 /tmp/recovery
restic restore latest --target /tmp/recovery --include /etc/nginx --include /var/www
sudo find /tmp/recovery/etc/nginx /tmp/recovery/var/www -maxdepth 2 -type f -printFor Borg, list the archives and inspect the selected archive before extracting it:
export BORG_REPO=ssh://[email protected]/./borg/myserver
export BORG_PASSCOMMAND='cat /etc/borg/passphrase'
borg list
borg extract --dry-run --list '::myserver-2026-11-27T02:00:00' etc/nginx var/wwwExtract only after the dry run shows the expected paths:
sudo install -d -m 700 /tmp/recovery
cd /tmp/recovery
borg extract '::myserver-2026-11-27T02:00:00' etc/nginx var/wwwThe restored files may have different ownership or permissions when examined in a temporary location. Compare them with the backup's intended metadata before placing them on a live system.
Rebuild and validate the server
A practical full recovery sequence is:
- Provision a replacement host with the required Linux distribution and network access.
- Install restic or Borg and configure read access to the repository.
- Restore
/etc, application files, user data, and required service data into the replacement host. - Recreate required users, groups, mount points, and package dependencies.
- Restore databases from logical dumps, then check ownership and extensions.
- Review configuration before starting services. Restore secrets only through the approved access process.
- Start services and inspect their logs with
journalctl. - Test SSH, web requests, scheduled jobs, database connections, and application workflows.
- Measure the elapsed time and record missing files, undocumented steps, or permission problems.
| Check | Evidence |
|---|---|
| Repository access | The selected snapshot or archive can be listed |
| File recovery | Expected configuration and application files exist |
| Database recovery | A test query returns expected data |
| Service recovery | The service starts without errors |
| Application recovery | A real user workflow succeeds |
Exercise
Exercise
During a recovery drill, restic can list snapshots but restic restore reports an incorrect password. What should you check before creating a new repository?
Show answer
Check that the password file contains the original repository passphrase, has no unintended newline or formatting change, and is readable by the account running restic. Also verify that RESTIC_REPOSITORY points to the intended repository. A new repository would not recover the existing data.