TT Lab
Blog Get started
Learn Learning paths Courses

Backup and Restore

Restore Rehearsal

Continue in TT Lab

Goal

Carry out a recovery rehearsal with the backup set you built earlier, and measure the time to determine whether the RTO is met.

Why it matters

Recovery is all about order and verification. Extracting directly with -C / without going through a temporary path is an irreversible operation, and breaking the incremental restore order makes files that should exist disappear. And the RTO is a wish until you actually measure it — the number one reason RTO is missed in practice is not slow extraction but failing to count the time to bring the backup over.

The recovery objectives for this lab are RPO 24 hours and RTO 300 seconds.

The final incident is a restore where "the data is the same down to the byte, but the services will not start". A hash comparison vouches only for content, and who can open the file with what permissions is decided by the mapping between owner numbers and names, the permission bits, and extended permissions (ACLs). Whichever of the three is off, it looks like the same Permission denied, and the ways to fix the three differ.

Steps

  1. Create the /root/rest directory, and write the following two lines to /root/rest/objective.txt. RPO=24h / RTO=300s
  2. Restore /root/bk/full.tar.gz to /root/rest/check/. You must not touch the current /root/bk/src.
  3. Compare the restored copy with the original recursively and save the result to /root/rest/diff.txt. (There may be differences because of the file you added in step 4, so you may limit the comparison to the conf and data directories.)
  4. Restore only src/app/conf.yaml from the archive to /root/rest/one/. There must be no other files in that directory.
  5. Use --strip-components to remove src/ from the archive and restore to /root/rest/stripped/. As a result, /root/rest/stripped/app/main.py must exist.
  6. Restore the incremental set in order. Extract full → inc0 → inc1, in that order, into /root/rest/inc/; the result must be exactly the point of the last incremental: /root/rest/inc/src/app/new.py present, and src/logs/old.log, deleted just before inc1, absent.
  7. Perform the full recovery from step 2 through step 6 once more, timing it, and write the following two lines to /root/rest/timing.txt. ELAPSED=<초> / MEETS_RTO=<yes|no> (yes if within 300 seconds)
  8. Incident: raise incident bk-app-down, work out per service why all three services fail to start with Permission denied after the old server's backup was extracted on a new server, then, without widening permissions, restore the same owners, modes, and extended permissions as on the old server. The report is /root/incident/bk-app-down/report.txt (candidate codes are in the step description).

Notes

Record the recovery objectives

Create the /root/rest directory, and write the following two lines to /root/rest/objective.txt. RPO=24h / RTO=300s

The RPO and RTO are given in this lab. Write the values exactly.

Restore to a temporary path

Restore /root/bk/full.tar.gz to /root/rest/check/. You must not touch the current /root/bk/src.

Never extract directly into the current location. Use the option that specifies the restore location.

Compare with the original

Compare the restored copy with the original recursively and save the result to /root/rest/diff.txt. (There may be differences because of the file you added in step 4, so you may limit the comparison to the conf and data directories.)

There is a command that compares whole directories recursively. If there are no differences, it is silent.

Selective restore

Restore only src/app/conf.yaml from the archive to /root/rest/one/. There must be no other files in that directory.

If you pass the path inside the archive as an argument, only that is extracted. First confirm the exact path from the listing.

Restore with path adjustment

Use --strip-components to remove src/ from the archive and restore to /root/rest/stripped/. As a result, /root/rest/stripped/app/main.py must exist.

There is an option that specifies how many leading path elements to strip.

Restore in incremental order

Restore the incremental set in order. Extract full → inc0 → inc1, in that order, into /root/rest/inc/; the result must be exactly the point of the last incremental: /root/rest/inc/src/app/new.py present, and src/logs/old.log, deleted just before inc1, absent (the grader extracts the chain again from the same set and compares).

You must extract the full backup first, then the incrementals in order. If you extract an incremental like an ordinary archive, additions come in but deletions are not applied. Do not update the snapshot file during a restore.

Measure the recovery time

Perform the full recovery from step 2 through step 6 once more, timing it, and write the following two lines to /root/rest/timing.txt. ELAPSED=<초> / MEETS_RTO=<yes|no> (yes if within 300 seconds)

Compute the difference between the start and end times in seconds. Compare it with the objective to reach a verdict.

Incident: the restore is supposedly finished, but three services fail with Permission denied

Running incident bk-app-down raises the incident. Symptom: the old server (app01)'s backup /backup/bkapp/bkapp-1104.tar.gz was extracted to /srv/bkapp on the new server, but all three services, bkapp-web, bkapp-worker, and bkapp-report, fail to start with Permission denied (startup check bkappctl, logs in /var/log/bkapp/). Find the cause for each service and fix it so that each of the three services starts under its own account. The end state is the same owners (by name), modes, and extended permissions (ACLs) as on the old server, with the content unchanged. Starting them by widening permissions (777, o+r), changing the accounts' numbers or group memberships, or running the services as root is a failure. In /root/incident/bk-app-down/report.txt, write three lines, bkapp-web: <코드>, bkapp-worker: <코드>, and bkapp-report: <코드> (code), plus evidence: <관찰한 출력 한 줄> (one line of output you observed). Each service's code is one of the following: acl-lost (extended permissions were not restored), mode-lost (permission bits were trimmed), numeric-owner (owners were carried over by number and became other accounts), wrong-group (the account is missing a group membership).

Direction: root is not blocked by permission bits, so reproduce as the service account. Even with the same Permission denied, which of the three layers (owner, permission bits, extended permissions/ACLs) blocked it may differ per service. Tools: runuser -u --, ls -ln and ls -l, stat, getent and id, getfacl, tar -tv (with and without --numeric-owner). Concretely: look at the file owners both by number and by name and compare them with this server's account numbers. Compare the modes recorded in the archive with the current modes, and also look at the permission list the old server left alongside the backup (/backup/bkapp). The data is already the same, so what you must fix is the metadata.