diff --git a/flake.nix b/flake.nix index 9385733..4f109f7 100644 --- a/flake.nix +++ b/flake.nix @@ -1,6 +1,6 @@ # flake for blakes nixos config # define new devices in outputs -# generation: 288 current 2025-10-11 10:03:00 25.05.20251006.20c4598 6.12.50 * +# generation: 289 current 2025-10-11 11:25:44 25.05.20251006.20c4598 6.12.50 * { description = "blakes nix config"; inputs = { diff --git a/modules/system/backups.nix b/modules/system/backups.nix index 9415ee2..f9df240 100644 --- a/modules/system/backups.nix +++ b/modules/system/backups.nix @@ -56,6 +56,7 @@ in export BORG_PASSPHRASE="$(cat ${cfg.passwd_file})" export BORG_REPO="${cfg.repo}" timestamp="$(date +'%Y-%m-%d_%H:%M:%S')" + mode=all # init repo in needed if ! borg info "$BORG_REPO" >/dev/null 2>&1; then @@ -65,12 +66,29 @@ in echo "starting backup at $timestamp" - # loop for each backup - ${lib.concatStringsSep "\n\n" (lib.mapAttrsToList (bak_name: bak_paths: - '' - echo "------------ Backing up ${bak_name} ------------" - archive="$timestamp-${bak_name}" - echo "backing up: ${lib.concatStringsSep " " bak_paths.paths} → $archive" + if [ "$mode" = "sep" ]; then + # loop for each backup + ${lib.concatStringsSep "\n\n" (lib.mapAttrsToList (bak_name: bak_paths: + '' + echo "------------ Backing up ${bak_name} ------------" + archive="$timestamp-${bak_name}" + echo "backing up: ${lib.concatStringsSep " " bak_paths.paths} → $archive" + borg create \ + --verbose \ + --filter AME \ + --list \ + --stats \ + --show-rc \ + --compression lzma,9 \ + "$BORG_REPO::$archive" \ + ${lib.concatStringsSep " " bak_paths.paths} + else + # flatten all paths from cfg.baks into one big list + all_paths="${ + lib.concatStringsSep " " + (lib.flatten + (lib.mapAttrsToList (_: bak: bak.paths) cfg.baks)) + }" borg create \ --verbose \ --filter AME \ @@ -79,7 +97,8 @@ in --show-rc \ --compression lzma,9 \ "$BORG_REPO::$archive" \ - ${lib.concatStringsSep " " bak_paths.paths} + $all_paths + fi echo "pruning old backups for ${bak_name}..." borg prune -v --list "$BORG_REPO" \