Repository & SSH Tuning
Fixing lock_wait Timeouts & Stale SSH PID Repository Locks
Prevent overlapping systemd runs from failing on lock contention and diagnose stale lock.exclusive files left behind after abrupt network drops.
lock_wait: 60 · ServerAliveInterval 30 · Safe break-lock
Never Run borg break-lock Blindly in Automation
Automating borg break-lock before backups risks corrupting repository metadata if another legitimate borg create or compact process is still running. Always pair ServerAliveInterval=30 with lock_wait: 60 so dead SSH processes reap cleanly on their own.
Separating Check Schedules from Daily Backups
Configure Borgmatic checks frequency (e.g., repository every 2 weeks, archives monthly) inside the single serialized borgmatic service so checks run sequentially after create/prune/compact.
Measured Thresholds & Borgmatic Configuration
| Lock Failure Cause | Prevention in config.yaml | Safe Recovery |
|---|---|---|
| Overlapping Backup & Check | lock_wait: 60 to 300 seconds | Wait for active PID before failing systemd unit |
| Dead TCP/SSH Session | ssh_command: -o ServerAliveInterval=30 -o ServerAliveCountMax=3 | Terminates zombie server-side borg serve within 90s |
| Client Power Loss Crash | Persistent=true systemd timer | Verify no live borg process on slice, then run borg break-lock |