Repository & SSH Tuning
Btrfs & LVM-Thin Snapshot Hooks for Crash-Consistent Files
Freeze live application state cleanly using Borgmatic before_backup and after_backup hooks so open files never back up mid-write.
< 2s Snapshot Freeze · Zero Torn Files · Auto Cleanup
Always Register Cleanup Inside on_error Too
If an SSH drop or SIGTERM interrupts Borgmatic mid-backup, after_backup may be skipped unless you also attach snapshot removal to on_error. Lingering LVM snapshots slowly fill thin pools if left mounted.
Pointing source_directories at the Read-Only Snapshot
Mount the frozen LVM or Btrfs snapshot at /mnt/borg_snap and list /mnt/borg_snap inside source_directories so Borg reads a point-in-time consistent tree while live apps keep writing freely.
Measured Thresholds & Borgmatic Configuration
| Filesystem Layer | before_backup Hook | after_backup / on_error Cleanup |
|---|---|---|
| LVM-Thin Volume | lvcreate -s -n borg_snap /dev/vg0/data | lvremove -f /dev/vg0/borg_snap |
| Btrfs Subvolume | btrfs subvolume snapshot -r /srv /srv/.borg_snap | btrfs subvolume delete /srv/.borg_snap |
| SQLite / Embedded DB | sqlite3 app.db ".backup /tmp/app.bak" | rm -f /tmp/app.bak |