Backups, Archives, and Recovery

Archive creation is a step; accepted recovery is the test.

Package, compress, and inspect

COPYFILE_DISABLE=1 tar -czf report.tar.gz -C source .
tar -tzf report.tar.gz
gzip -t report.tar.gz

Use the complete owned fixture setup. Keep the archive outside source so it cannot include itself.

A valid compression stream does not prove correct selection or recoverability.

Extract only controlled fixtures here

tar -xzf fixture.tar.gz -C restore
cmp source/report.txt restore/report.txt

Restore is a newly created empty directory away from originals.

External archives can contain dangerous paths, links, special files, and metadata. Listing is useful but not a complete security validator. The automated lesson extracts only its self-created regular-file fixtures.

Define the recovery policy

Requirement Question
Scope Which data and configuration?
Consistency What makes the captured state coherent?
Recovery point objective How much recent work may be lost?
Recovery time objective How long may recovery take?
Independent copy Which failures can one copy survive?
Retention and keys Which tested versions and keys remain usable?

A live database needs a database-consistent method and restore test.

Retention is a reviewed decision

Enumerate candidates, preserve the last tested good recovery point, and verify independent copies and any decryption-key recovery.

A filename/age match is not by itself permission to delete. The executable fixture writes a retention proposal and removes no backup.

A transfer from Chapter 17 is not a complete backup policy.

Restore acceptance has several parts

  • Expected path set, including unexpected extra files.
  • Exact bytes or known hashes.
  • Required modes and ownership context.
  • Application-specific consistency and behavior.
  • Transcript of commands, time, status, and limitations.

The fixture verifies two files including a spaced filename, then checks an owner-only restored mode separately.

Make failed recovery visible

An invalid archive returns nonzero with diagnostics. Empty output after failure is not a valid empty backup.

The changed-copy fixture detects a mismatch while the original baseline remains unchanged. Do not regenerate a baseline from the damaged receiver.

A restored file's presence alone is insufficient acceptance.

Consolidate on your VM

Complete the graded lab on your VM. Its Part 4 schedules the backup with a timer, damages copies on purpose, and checks which tests catch them.

Document what was not tested: database recovery, arbitrary external archives, full ACL/xattr semantics, and encrypted offsite-key recovery need their own scenarios.

Sources: Linuxize tar, GNU tar, and earlier integrity/transfer contracts linked in the lessons. All extraction fixtures are self-created and owned.