From 1a87b3af470842e4399a990cf274018323a7f700 Mon Sep 17 00:00:00 2001 From: Chris Toph Date: Sun, 20 Apr 2025 03:11:52 -0400 Subject: [PATCH] Small borg-wrapper refactor, now uses push/pop directory changes to back up only the basename --- home/toph/common/optional/gaming/switch.nix | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/home/toph/common/optional/gaming/switch.nix b/home/toph/common/optional/gaming/switch.nix index cd4c037..a81a822 100644 --- a/home/toph/common/optional/gaming/switch.nix +++ b/home/toph/common/optional/gaming/switch.nix @@ -19,9 +19,6 @@ let borg-wrapper = pkgs.writeScript "borg-wrapper" '' #!${lib.getExe pkgs.fish} - # Enable strict error handling - set -e - # Parse arguments set -l CMD @@ -59,10 +56,14 @@ let set -l tag $argv[1] set -l timestamp (date +%Y%m%d-%H%M%S) echo "Creating $tag backup: $timestamp" + + # Push to parent directory, backup the basename only, then pop back + pushd (dirname "$BACKUP_PATH") >/dev/null ${pkgs.borgbackup}/bin/borg create --stats --compression zstd,15 \ --files-cache=mtime,size \ --lock-wait 5 \ - "$BORG_REPO::$tag-$timestamp" "$BACKUP_PATH" || true + "$BORG_REPO::$tag-$timestamp" (basename "$BACKUP_PATH") || true + popd >/dev/null end function prune_backups