Damaged-backup example for https://srvscripts.com/scripts/backup-verify/

make-damaged-backups.sh builds a small test tree of cPanel-style backups (about 1.7 MB, synthetic data, in under
a second) with known damage. Run backup-verify.sh against it and compare with expected-output-quick.txt and
expected-output-deep.txt. Needs bash, GNU tar, gzip, coreutils (date -d, touch -d, stat -c) and awk.

  bash make-damaged-backups.sh bv-demo
  bash backup-verify.sh bv-demo --accounts-file bv-demo/accounts.txt            # quick test: 5 problems, exit 1
  bash backup-verify.sh bv-demo --accounts-file bv-demo/accounts.txt --deep     # deep test:  7 problems, exit 1

The tree: three dated runs (2 days ago, yesterday, today) under bv-demo/DATE/accounts/, a mysql/ folder and
accounts.txt with the accounts that must have a fresh backup.

  Account   What is wrong in today's run                                  Quick test   --deep
  alice     nothing                                                       OK           OK
  bob       no file today; newest backup is 50 hours old                  FAIL         FAIL      (age and coverage)
  carol     archive 69% smaller than yesterday's                          FAIL         FAIL      (shrink)
  dave      one byte inverted inside the gzip data                        FAIL         FAIL      (gzip -t / listing)
  erin      valid gzip around a tar stream cut in half, normal size       OK           FAIL      (tar listing)
  wpdb      today's SQL dump has no "-- Dump completed" trailer           OK           FAIL      (trailer)
  grace     listed in accounts.txt, never backed up                       FAIL         FAIL      (coverage)

erin and wpdb are the point of the example: their files are fresh, the right size and pass gzip -t, so a quick check
and most backup dashboards call them good. Only listing the archive (--deep) and reading the end of the dump find them.

Checking the damage without the script
  gzip -t bv-demo/$(date -u +%F)/accounts/dave.tar.gz        # "invalid compressed data--crc error", exit 1
  gzip -t bv-demo/$(date -u +%F)/accounts/erin.tar.gz        # exit 0: the gzip layer is fine
  tar -tzf bv-demo/$(date -u +%F)/accounts/erin.tar.gz       # tar: Unexpected EOF in archive, exit 2
  zcat bv-demo/mysql/wpdb_$(date -u +%F).sql.gz | tail -1    # an INSERT line, not "-- Dump completed on ..."

Your output will differ from the expected files in the dates, file ages and sizes (the folders are named after the day
you run it, and awk implementations differ slightly), not in which lines are OK or FAIL. We ran it with gawk and mawk
on 18 October 2026 with backup-verify 2.1.2 and got the same OK/FAIL lines.

What this example does not prove
  A backup that passes every check here can still fail to restore: a listing shows that the archive is complete, not
  that the files in it are the right ones or that the database loads. The only proof is a real restore: restore one
  account and one database to a test server (or a scratch database) on a schedule, open the site, run a query, and
  write down how long it took. For a FreePBX server, see https://srvscripts.com/guides/restore-a-freepbx-backup/.

Licence: free to copy and reuse.
