A backup is useless if it is silently corrupt. This episode teaches integrity verification with borg check, content verification with borg check --verify-data, scheduling monthly checks, and routine maintenance: compact, log reviews, and disk health monitoring so that damage is discovered before a restore is needed.

After backups run automatically via borgmatic and are sent remotely over SSH, there is one danger that often slips through: silently corrupt backups. Disks can suffer bit rot, networks can cut transfers, and nobody knows until restore time. Episode 12 closes this gap: regular integrity verification and disciplined maintenance.
borg check /backup/borgborg check verifies the internal consistency of the repository:
The result is "yes, the repository is structurally healthy". Note: this is not proof that the file contents are correct — that is the job of --verify-data.
borg check --verify-data /backup/borg--verify-data re-reads every chunk and verifies its checksum/hash. This is the most thorough check, but also the slowest — taking time proportional to the total stored data. The strategy:
borg check: monthly (cheap, fast).borg check --verify-data: once a year or after a suspicious event (e.g. the disk ran full, a crash, or I/O error reports).In episode 9 we already defined check frequencies in borgmatic:
checks:
- name: repository
frequency: 1 month
- name: data
frequency: 1 yearborgmatic remembers when the last check ran (stored in its cache) and only runs the ones that are due — so a check does not slow down every daily backup.
borg compact cleans up segments that hold unused chunks after prune/delete. Run it as part of the routine:
borg compact /backup/borgIf you use borgmatic, add a compact: true line to the config or call a scheduled borgmatic compact.
Failed backups usually leave a trail in the logs. Make a short review ritual:
tail -50 /var/log/borgmatic.logLook for patterns: does it always fail on the same file? Does backup duration spike? A consistently rising duration can signal a weakening disk or data accumulating without exclusions.
The Borg repository depends entirely on disk health. Monitor it with SMART:
sudo smartctl -H /dev/sdb
sudo smartctl -A /dev/sdb | grep -E "Reallocated|Pending|CRC"Reallocated_Sector_Ct or Current_Pending_Sector is a red flag: migrate the repository to a healthy disk immediately and run borg check --verify-data.Warning
borg check --repair does exist to repair a problematic repository, but it deletes data that cannot be repaired — corrupt chunks referenced by an archive are discarded along with the related files. Never run it without a backup copy of the repository and without understanding the consequences.
Daily : automatic backup (borgmatic) + quick log check
Weekly : borg check (repository) + disk space review
Monthly : borg compact + smartctl -H + verify one restore
Yearly : borg check --verify-data + full restore drillThe key to this calendar: everything is scheduled, nothing depends on memory. Cron or a systemd timer handles the daily; the monthly check can also be scheduled via borgmatic's frequency.
borg check verifies the structural consistency of the repository.borg check --verify-data verifies the contents of every chunk — thorough but slow.frequency without slowing down daily backups.--repair deletes data that cannot be repaired — be careful.In episode 13 we lock the repository down from the backup's worst enemy: repository security — append-only mode as an anti-ransomware defense (Borg 1.2+), authenticated encryption, and the SSH lock with command="borg serve --restrict-to-path ...".