Timestamped Directory Backup
Create a compressed, timestamped tar archive of a directory and verify it.
$ webtoolist --script restore-verify-tar
Check an archive's checksum, list its contents, and compare a sample safely.
restoretarverifybackupDependencies: tar, sha256sum, mktemp
#!/usr/bin/env bash
set -euo pipefail
archive="${1:-}"
[[ -f "$archive" ]] || { echo "usage: $0 ARCHIVE [CHECKSUM_FILE]" >&2; exit 1; }
if [[ -n ${2:-} ]]; then
sha256sum -c "$2"
fi
echo "== archive contents (first 20 entries) =="
tar -tzf "$archive" | sed -n '1,20p'
tmp="$(mktemp -d)"
trap 'rm -rf -- "$tmp"' EXIT
tar -xzf "$archive" -C "$tmp"
echo "extracted to: $tmp (removed on exit)"
echo "files: $(find "$tmp" -type f | wc -l)"
du -sh "$tmp"
./restore-verify-tar /mnt/backups/projects-20260924-120000.tar.gz /mnt/backups/projects-20260924-120000.tar.gz.sha256
Related scripts
Create a compressed, timestamped tar archive of a directory and verify it.
Mirror a directory to a backup target with dry-run, delete protection, and a log.
Use SQLite's online backup API to copy a live database consistently.