diff --git a/modules/nixos/base/restic-backup.nix b/modules/nixos/base/restic-backup.nix index aa6e1bff..7c9c9739 100644 --- a/modules/nixos/base/restic-backup.nix +++ b/modules/nixos/base/restic-backup.nix @@ -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 = ''