Backups will definitely have problems — what separates professionals is how they diagnose. This episode covers Borg's debugging toolkit: borg check, --debug-topic, and BORG_LOGGING_CONF, plus common cases such as repo lock, corruption, and version mismatch, and recovery from damaged segments with preventive practices.

At some point, your backup will fail — that is not an "if", but a "when". What separates an experienced operator is not the ability to avoid problems, but the speed of diagnosing and recovering from them without making things worse. Episode 16 equips you with Borg's debugging toolkit: borg check as the first-line checker, --debug-topic for detailed traces, up to structured logging with BORG_LOGGING_CONF.
Before blaming anything, verify the repository's health with borg check /backup/borg. The result points the way: errors in the index/segment indicate a repository problem; errors while rebuilding the cache indicate a local client problem.
Borg can enable debug logging per topic — far more useful than the noisy full debug:
borg create --debug-topic=archive,chunker --list /backup/borg::test /homeCommon topics: archive (archive metadata), chunker (the chunk-splitting process), repository, cache, ssh. Combining --debug + --debug-topic gives maximum detail.
For long-term debugging in production, use your own logging configuration:
[loggers]
keys = root, repository
[handlers]
keys = file, console
[formatters]
keys = standard
[logger]
level = INFO
[logger.repository]
level = DEBUG
[handler_file]
class = FileHandler
level = DEBUG
args = ('/var/log/borg.log', 'a', 'UTF-8', 1)
[handler_console]
class = StreamHandler
level = WARNING
[formatter_standard]
format = %(asctime)s %(levelname)s %(name)s %(message)sEnable it with export BORG_LOGGING_CONF=/etc/borg/logging.conf then run borg commands as usual. Detailed logs go to /var/log/borg.log while the console stays clean — a healthy pattern for automation.
Failed to create/acquire the lock on /backup/borgCause: another borg process is running, or an old lock from a crash/power outage. First check processes with ps aux | grep "[b]org". If there is no process but the lock remains, it is a stale lock — never rm lock files manually; use borg break-lock /backup/borg, and only if you are sure it is genuinely stale.
Repository or key data seem corruptFirst step: do not panic and do not jump straight to --repair. Diagnose with borg check /backup/borg --debug-topic=repository:
borg check rebuilds the index from the segments.borg check --repair, with a copy of the repository elsewhere first. Remember the warning from episode 12: --repair deletes data that cannot be repaired.Repository was made with a different security feature levelA repo created by Borg 2.0 cannot be read by 1.4, and vice versa. Quick diagnosis: compare borg --version with the version in the repository config. The fix: align the client and server versions (episode 15), or for 2.0-beta repos do not force 1.x to read them — build a new repo with the correct version.
Connection closed by remote hostTest the connection manually with BORG_RSH='ssh -v' borg list borg@backup-host:/srv/borg/backup. -v shows the SSH handshake; failures in the command= of authorized_keys usually appear clearly here.
When a segment is truly damaged and holds chunks referenced by an archive:
borg check --verify-data — which chunks fail.borg check --repair discards the corrupt chunks — the related files are lost from the archive, but other archives stay intact.The most effective preventive practice: always have a second repo copy and routine borg check. The best recovery is the one never needed.
Warning
borg check --repair and borg break-lock are two weapons that can save or destroy. Both permanently modify the repository. Before using them: back up the repository first, understand what they do, and if in doubt — ask the community (episode 21).
borg break-lock, not rm on files under lock.exclusive.BORG_LOGGING_CONF so traces are stored, not lost in the terminal.borg check, not assumptions.--debug-topic gives per-topic traces; BORG_LOGGING_CONF stores logs for production.borg break-lock), corruption (check → careful repair), version mismatch, and SSH failures.--repair as a last resort.In episode 17 we look to the future: Borg 1.4.5 vs Borg 2.0 — why 1.4.5 remains the production choice, what 2.0 overhauls (repo format, hash index, --match-archives, segment management), and when you may move.