Skip to content

Add per-domain disk space usage to backup report - #25

Merged
locus313 merged 1 commit into
mainfrom
feature/backup-report-disk-space
Aug 25, 2026
Merged

Add per-domain disk space usage to backup report#25
locus313 merged 1 commit into
mainfrom
feature/backup-report-disk-space

Conversation

@locus313

Copy link
Copy Markdown
Collaborator

Summary

Adds per-domain disk space usage (human-readable) to the WordPress backup cleanup report, as a follow-up to the recent dates/formatting improvements.

Changes

  • scan_domains() now captures each backup file's size alongside its mtime date, using a single find -printf '%T@ %s %p' pass
  • New human_size() helper formats byte counts as human-readable strings (e.g. 15.0MiB, 500.0KiB) via numfmt, with a plain <bytes>B fallback if numfmt isn't available
  • Plain-text report (console/dry-run): each domain's found-backups line now shows size: <human-readable>
  • HTML email report: new "Disk Space" column in the found-by-domain table
  • Removed-file entries now include size, e.g. backup-1.tar.gz (2025-07-20, 5.0MiB)
  • Summary line/section in both report formats now shows total disk space across all domains
  • Domains with zero backups correctly show 0.0B (no crash)

Testing

  • shellcheck passes cleanly (only the pre-existing, intentional SC2086 info on the unquoted BACKUP_PATH glob)
  • Manual functional test with temp vhost trees containing files of known sizes (5MiB, 10MiB, 500KiB) confirmed correct per-domain and total sizes in both plain-text and HTML output
  • Verified the zero-backup-domain edge case doesn't crash and shows 0.0B
  • Verified HTML email output (via stubbed mail command) renders the new column correctly

Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com

- Capture backup file sizes in scan_domains() alongside dates, using
  find's -printf to grab epoch/size/path in one pass
- Add human_size() helper using numfmt (falls back to plain bytes if
  numfmt is unavailable) to format sizes as human-readable (e.g. "1.2GiB")
- Add a "Disk Space" column to the found-by-domain table in both the
  plain-text report (console/dry-run) and the HTML email report
- Append size to each removed-file entry, e.g. "backup-1.tar.gz (2025-07-20, 5.0MiB)"
- Add total disk space used to the summary line/row in both report formats
- Update README and script header docs

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@locus313
locus313 merged commit 2ecafc3 into main Aug 25, 2026
1 check passed
@locus313
locus313 deleted the feature/backup-report-disk-space branch August 25, 2026 00:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant