Linux Advanced 2 06 — Encrypted Backups and Restore Drills

Linux course index · Linux Advanced 2 category · Lesson 6 of 7

AI disclosure — AI-generated content, posted as is. AI can make mistakes. This extension adds new material and links related posts from this site. The newly written explanations and examples may be freely reused. Linked source material retains its own terms.

Learning goal

Create an encrypted Restic snapshot and verify a real restore into a separate directory.

Concepts and setup

The site shows tar archives and database dumps. This extension introduces encrypted, deduplicated repository snapshots. A repository check can find some consistency problems, but only a restore exercise proves you can retrieve the specific data you need. Recovery point objective (RPO) describes tolerable data loss in time. Recovery time objective (RTO) describes tolerable unavailability. This is a local fixture, not a disaster-resilient storage design.

Use a disposable VM with restic and a new temporary directory. Choose a lab-only passphrase when prompted and remember it for the four commands. In real operations, use an approved secret mechanism and keep separate protected copies of both the data and the recovery credentials.

Initialize and check a repository

lab=$(mktemp -d)
mkdir "$lab/data" "$lab/restore"
printf 'release=training\n' > "$lab/data/settings.txt"
export RESTIC_REPOSITORY="$lab/repo"
restic init
restic backup --tag oe-recovery "$lab/data"
restic snapshots
restic check

Possible output

created restic repository ...
...
snapshot 92d7e125 saved
...
no errors were found

Never put the real passphrase in shell history. The sample ID changes. A normal check does not necessarily read every data pack. Discuss the time and bandwidth cost of deeper checks in production.

Restore separately and compare actual bytes

restic restore latest --tag oe-recovery --target "$lab/restore"
restored=$(find "$lab/restore" -type f -name settings.txt -print -quit)
test -n "$restored" && cmp "$lab/data/settings.txt" "$restored" &&
  printf 'restored bytes match\n'
unset RESTIC_REPOSITORY

Possible output

restoring snapshot 92d7e125 ... to /tmp/tmp.ABC/restore
...
restored bytes match

This fixture contains one uniquely named file. Production restores should use an identified snapshot, preserve expected metadata, and verify application-level data as well.

Questions only

Quick-check questions

  1. Why is a snapshot ID more precise than latest?
  2. Why keep recovery credentials apart from the protected data?

Assessment questions

  1. A new snapshot is needed at most every hour and service must be restored within four hours. Identify RPO and RTO.
  2. Name two steps to prove a restore worked beyond seeing the command exit 0.
  3. What problem remains if both the original and the repository live on one laptop?

Questions and answers

Quick-check answers

  1. Why is a snapshot ID more precise than latest?
    Answer — It selects a known version even if newer snapshots appear.
  2. Why keep recovery credentials apart from the protected data?
    Answer — Losing the only recovery credentials can make the encrypted repository unreadable.

Assessment answer key

  1. A new snapshot is needed at most every hour and service must be restored within four hours. Identify RPO and RTO.
    Answer — RPO is one hour and RTO is four hours.
  2. Name two steps to prove a restore worked beyond seeing the command exit 0.
    Answer — For example, compare expected contents and metadata, query restored data, or test the recovered service from a client.
  3. What problem remains if both the original and the repository live on one laptop?
    Answer — The same device loss, compromise, or storage failure can destroy both copies.

Related source articles on this site

Technical references

Continue the course

Previous lesson 05 — Kernel Modules and Resource Limits. Next lesson 07 — Capstone: Build, Diagnose, and Recover a Linux Service.

Linux course index · Linux Advanced 2 category · Lesson 6 of 7

Leave a Reply