Linux Survival Basics
List Contents of a Backup Tarball
You need to see what a backup tarball contains before restoring it.
Command
tar -tf archives/site-backup.tar | sort | head
What changed
Nothing changes. The command lists archive member names.
Danger
safe
When to use it
Use before extracting a backup archive or when checking whether expected files are present.
When not to use it
Do not treat a file listing as content verification; pair it with checksums when possible.
Undo or recovery
No undo needed because this command is read-only.
Expected output
A sorted sample of paths stored inside the tar archive.
demo script
Disposable terminal steps
ls -lh archives/site-backup.tartar -tf archives/site-backup.tar | sort | head
simulated output
What it looks like
::fixture-ready::
$ ls -lh archives/site-backup.tar
-rw-r--r-- 1 root root 10K Jun 25 13:19 archives/site-backup.tar
::exit-code::0
$ tar -tf archives/site-backup.tar | sort | head
./
./app/
./app/config.yml
./assets/
./assets/logo.svg
./content/
./content/about.md
./content/index.md
::exit-code::0
YouTube Short
Inspect tar before restore.
Use tar -tf to list archive contents before extracting or restoring anything.
LinkedIn hook
You can inspect an archive without extracting it.
Question: Do you inspect tarball contents before extracting backups?
experiments
A/B tests to run
Metric: watch_time
A: Do not extract yet.
B: List archive contents first.