The server hit 86% disk with 3.4 GB left. The biggest directory was deploy backups: 278 directories, 8280 MB.
The recorded directory total was 8280 MB; excluding public-downloads.before left 276 MB. That difference measures the remaining directories, not unique bytes after content-hash deduplication. The original summary is retained below.
The record attributed 8004 MB to 228 download-directory snapshots. Their contents and sizes can change over time; this is not 228 identical copies of one fixed 44 MB directory.
Measure first, delete second
Every deploy snapshots the site’s current state. Looking at what one snapshot contains:
4.0K 404.php.before
28K functions.php.before
500K personal-site-experience.php.before
...
44M public-downloads.before <-- 44 of the 45 MB
8.0K personal-site.conf.before
Of a 45 MB backup, 44 MB is public-downloads.before, a complete copy of the static downloads directory. That directory changes when I update lab materials, which rarely happens during a normal deployment.
The blunter evidence is diffing two adjacent backups:
$ diff -rq 20260801-114501/ 20260801-122255/ | wc -l
3
The command produced three difference lines. Establishing that 238 of 241 files were byte-identical also requires a file manifest, path pairing and the diff exit status. A line count alone does not establish file identity.
Grouping by day, the heaviest ones:
20260602 26 deploys 1170 MB
20260604 17 deploys 765 MB
20260801 13 deploys 588 MB
Repeated snapshots accumulate with deployment count. The 44 MB figure describes one example snapshot; 8004 MB is the historical aggregate, not a fixed-size multiplication model.
Separate directory usage, compression and deduplication
total 8280 MB
of which public-downloads 8004 MB (228 copies)
genuinely unique 276 MB
Compare historical, latest and live paths and content hashes before deletion. The difference below found files missing from both the latest snapshot and the live directory, so live content alone cannot replace every historical download snapshot.
The archive plan excluded repeated directories, retained a current snapshot and separately recovered history-only content. Streaming avoided an additional archive file on the server.
ssh server "cd /srv/backups && tar czf - --exclude=public-downloads.before ." \
> backups-unique.tar.gz
The record compares 8280 MB of directory usage with about 96 MB of compressed archives: 56 MB, 37 MB and 3 MB of recovered extras. This combines exclusions, compression and recovery across different size measures; it is not a standalone deduplication ratio.
The seven files I nearly lost
I still needed to check the newest snapshot for missing files. Older snapshots might contain files that had since been deleted.
Before deleting anything, I compared three sets to check for missing historical files:
# every file path that ever appeared in any historical snapshot
find . -path "*/public-downloads.before/*" -type f \
| sed "s#.*/public-downloads.before/##" | sort -u > all.txt
# newest snapshot + the live directory
cat new.txt live.txt | sort -u > keep.txt
comm -23 all.txt keep.txt # present only in history
union of all history 220 files
newest snapshot 181
live directory 185
history only 35
Thirty-five. Going through them:
- 23 are macOS
._metadata (AppleDouble resource forks, picked up when copying from a Mac) — worthless - 5 had simply moved into a subdirectory —
Iris.csvwent from the root toiris-kmeans/Iris.csv; different path, same file, still live - 7 genuinely existed only in historical backups: a
shanhaijue-media/set containing a hero image, a validation figure, a manifest and the script that generated them
Those seven are absent from both the live directory and the newest snapshot. Running “keep the last 10 backups, delete the rest” would have destroyed them permanently — silently, with no error, because nothing still referenced them.
Recovering them took under a minute. This preserved files that were missing from both the live directory and the latest snapshot.
Choosing streamed archiving
Streaming was chosen to reduce extra server disk use.
With 3.4 GB free and an 8.3 GB source, an uncompressed staging copy would exceed free space. That does not establish whether a compressed archive would fit. Streaming writes the archive directly to local storage.
I therefore had tar write to stdout and piped the stream over ssh, without storing the archive on the server:
ssh server "cd /srv/backups && tar czf - --exclude=public-downloads.before ." \
> backups-unique.tar.gz
Streaming required an integrity check: a dropped connection could leave a truncated gzip file. The ssh link dropped a dozen times that evening, so I verified each transfer and restarted failures from the beginning. The output of tar czf - could not be resumed directly.
for i in 1 2 3 4 5 6; do
ssh "$REMOTE" "$CMD" > "$OUT.part" \
&& gzip -t "$OUT.part" 2>/dev/null \
&& { mv "$OUT.part" "$OUT"; break; }
echo "incomplete transfer, retrying"
sleep 5
done
Check SSH and remote tar status, gzip -t, archive membership and content. OpenSSH normally returns 255 for communication errors and the remote command status otherwise. A cut link is not normally a successful exit. A valid gzip stream can still omit required files.
Verify, then delete
The original pre-deletion results are retained below. The 8957-entry size/list comparison, 25-file hash sample and three gzip checks cover different layers; the sample does not hash every file.
file list compared one by one 8957 / 8957 missing 0 size mismatch 0
random sha256 sample 25 / 25 match
gzip integrity all 3 archives pass
The sampling step initially returned one BAD. It turned out my script called ssh twice per file, and over a flaky link one of the two calls returned empty — a false positive from the verification tool itself. Batching all the hashes into a single ssh call gave 25/25.
Trusting the BAD would have sent me looking for nonexistent transfer corruption; ignoring it could have missed real damage. A failed check requires examining both the object under test and the verification tool.
The record also includes cloud checks. rclone check normally compares size and a common supported hash. Without a common hash, it cannot establish a full content-hash comparison; use a download check when needed. The original command result follows:
0 differences found
5 matching files
I then downloaded the cloud files in full and recomputed their hashes for comparison with the local originals:
rclone cat "$DEST/$f" | sha256sum
Hashing a full readback checks the returned bytes. Retain command statuses and object lists for both checks. Enable pipefail for the pipeline: a successful sha256sum alone can hide a failed download.
Only once all three sha256 values matched did the delete run. Disk went from 86% to 53%, free space from 3.4 GB to 11 GB.
The selected ten snapshots covered one debugging burst. Choose retention using deployment frequency, rollback windows, delayed discovery of mistakes and tested archive recovery.
Closing the tap
To prevent the same accumulation, I changed the deployment script to skip large static assets when creating a backup:
rsync -a --exclude 'anime-matting' \
"$SITE/public-downloads/" "$BACKUP/public-downloads.before/"
Per-deploy backup went from 99 MB to 45 MB. (It was 99 because a 53 MB model file had recently landed in that directory — same mechanism, double the cost.)
Three things worth keeping
The recorded download-snapshot share is 8004/8280≈96.7% of directory usage. A duplicate-byte fraction requires content hashes and treatment of hard links, sparse files and logical sizes.
Calculate the set difference before deleting historical data. Keeping only the latest snapshot would have lost files here. The comm -23 comparison identified them.
Repeated files add a fixed cost to each deployment backup. The policy copied unchanged large files into every snapshot. Frequent deployments during debugging multiplied that cost by a few dozen.