Back to commands

Hosting Operations

Deletes or truncates files

Extract a Backup Into a Restore Sandbox

You need to extract a backup into a dedicated restore-sandbox directory and list the restored files.

Command

BACKUP_ROOT=/srv/backups/site RESTORE_SANDBOX=/tmp/linuxoneliners-restore/full && rm -rf "$RESTORE_SANDBOX" && mkdir -p "$RESTORE_SANDBOX" && tar -xf "$BACKUP_ROOT/2026-06-25/site.tar" -C "$RESTORE_SANDBOX"

Before you run this

System impact: Deletes, truncates, or overwrites data. Requires backup, preview, and exact path review before production use.

When not to use it: Do not run extraction into /, /var/www, or a live application directory during a drill.

Expected output

A restored file list under restore-sandbox/full.

System impact

Deletes or truncates files. The existing restore-dr/restore-sandbox/full directory is removed and recreated, then the archive is extracted there.

When to use it

Use for restore drills where writing into an isolated sandbox is intentional.

When not to use it

Do not run extraction into /, /var/www, or a live application directory during a drill.

Recovery / rollback

Remove the restore-dr/restore-sandbox/full directory from the example copy. Never point the rm -rf path at production data.

next steps

Related commands

Hosting Operations Deletes data

Verify Restored File Checksums

A restore is not validated until the bytes match.

BACKUP_ROOT=/srv/backups/site RESTORE_SANDBOX=/tmp/linuxoneliners-restore/full && rm -rf "$RESTORE_SANDBOX" && mkdir -p "$RESTORE_SANDBOX" && tar -xf "$BACKUP_ROOT/2026-06-25/site.tar" -C "$RESTORE_SANDBOX" && (cd "$RESTORE_SANDBOX" && sha256sum -c CHECKSUMS.sha256)
Hosting Operations Deletes data

Check Required Files After Restore

A successful extraction still needs a required-file check.

BACKUP_ROOT=/srv/backups/site REQUIRED=/srv/backups/site/required-files.txt RESTORE_SANDBOX=/tmp/linuxoneliners-restore/full && rm -rf "$RESTORE_SANDBOX" && mkdir -p "$RESTORE_SANDBOX" && tar -xf "$BACKUP_ROOT/2026-06-25/site.tar" -C "$RESTORE_SANDBOX" && find "$RESTORE_SANDBOX" -type f | sed "s#^$RESTORE_SANDBOX/##" | sort | comm -23 "$REQUIRED" -
Hosting Operations Deletes data

Diff Restored Config Against Expected

A restored config can exist and still be the wrong config.

BACKUP_ROOT=/srv/backups/site EXPECTED_CONFIG=/srv/backups/site/expected/app/config.yml RESTORE_SANDBOX=/tmp/linuxoneliners-restore/full && rm -rf "$RESTORE_SANDBOX" && mkdir -p "$RESTORE_SANDBOX" && tar -xf "$BACKUP_ROOT/2026-06-25/site.tar" -C "$RESTORE_SANDBOX" && diff -u "$EXPECTED_CONFIG" "$RESTORE_SANDBOX/app/config.yml"
Hosting Operations Read-only

Find Missing Files in an Old Backup

The fastest failed restore drill is the one that finds missing critical files early.

BACKUP_ROOT=/srv/backups/site REQUIRED=/srv/backups/site/required-files.txt && tar -tf "$BACKUP_ROOT/2026-06-24/site.tar" | sed 's#^./##' | sort | comm -23 "$REQUIRED" -
Hosting Operations Read-only

List Archive Contents Before Extracting

You can inspect a tar backup before it writes a single file.

BACKUP_ROOT=/srv/backups/site && tar -tf "$BACKUP_ROOT/2026-06-25/site.tar" | sed 's#^./##' | sort
Study mapping

Use this as independent command practice: read the notes, predict the output, then compare it with the example before using a real shell.

  • LPIC-1 style command-line practice
  • LFCS style performance-task practice
  • Linux+ style troubleshooting review

Independent study support only. No affiliation, endorsement, exam dumps, or real exam questions.