fix(restic): drop a stale btrfs snapshot before taking a new one

Cleanup runs as ExecStopPost, which a power loss mid-backup skips; the
leftover @restic-snapshot then failed every later run.

Assisted-by: Claude Code (claude-opus-5-5)
This commit is contained in:
Ryan Yin authored and ryan4yin | 二花 committed 2026-11-01 10:51:51 -06:00
1 parent 32620ed9db
commit 8b22aec1bb
1 file changed
+4
+4
View File
@@ -200,7 +200,11 @@ in
}
// lib.optionalAttrs (cfg.snapshotSource != null) {
# Left behind if a backup was cut off by a power loss.
backupPrepareCommand = ''
if [ -e ${snapshotPath} ]; then
${pkgs.btrfs-progs}/bin/btrfs subvolume delete ${snapshotPath}
fi
${pkgs.btrfs-progs}/bin/btrfs subvolume snapshot -r ${cfg.snapshotSource} ${snapshotPath}
'';
backupCleanupCommand = ''