289 current 2025-10-11 11:25:44 25.05.20251006.20c4598 6.12.50 *

This commit is contained in:
2025-10-11 11:39:44 -05:00
parent fec6c6c146
commit 0d78ee24a0
2 changed files with 27 additions and 8 deletions

View File

@@ -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 = {

View File

@@ -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" \