289 current 2025-10-11 11:25:44 25.05.20251006.20c4598 6.12.50 *
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
# flake for blakes nixos config
|
# flake for blakes nixos config
|
||||||
# define new devices in outputs
|
# 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";
|
description = "blakes nix config";
|
||||||
inputs = {
|
inputs = {
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ in
|
|||||||
export BORG_PASSPHRASE="$(cat ${cfg.passwd_file})"
|
export BORG_PASSPHRASE="$(cat ${cfg.passwd_file})"
|
||||||
export BORG_REPO="${cfg.repo}"
|
export BORG_REPO="${cfg.repo}"
|
||||||
timestamp="$(date +'%Y-%m-%d_%H:%M:%S')"
|
timestamp="$(date +'%Y-%m-%d_%H:%M:%S')"
|
||||||
|
mode=all
|
||||||
|
|
||||||
# init repo in needed
|
# init repo in needed
|
||||||
if ! borg info "$BORG_REPO" >/dev/null 2>&1; then
|
if ! borg info "$BORG_REPO" >/dev/null 2>&1; then
|
||||||
@@ -65,12 +66,29 @@ in
|
|||||||
|
|
||||||
echo "starting backup at $timestamp"
|
echo "starting backup at $timestamp"
|
||||||
|
|
||||||
# loop for each backup
|
if [ "$mode" = "sep" ]; then
|
||||||
${lib.concatStringsSep "\n\n" (lib.mapAttrsToList (bak_name: bak_paths:
|
# 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 ${bak_name} ------------"
|
||||||
echo "backing up: ${lib.concatStringsSep " " bak_paths.paths} → $archive"
|
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 \
|
borg create \
|
||||||
--verbose \
|
--verbose \
|
||||||
--filter AME \
|
--filter AME \
|
||||||
@@ -79,7 +97,8 @@ in
|
|||||||
--show-rc \
|
--show-rc \
|
||||||
--compression lzma,9 \
|
--compression lzma,9 \
|
||||||
"$BORG_REPO::$archive" \
|
"$BORG_REPO::$archive" \
|
||||||
${lib.concatStringsSep " " bak_paths.paths}
|
$all_paths
|
||||||
|
fi
|
||||||
|
|
||||||
echo "pruning old backups for ${bak_name}..."
|
echo "pruning old backups for ${bak_name}..."
|
||||||
borg prune -v --list "$BORG_REPO" \
|
borg prune -v --list "$BORG_REPO" \
|
||||||
|
|||||||
Reference in New Issue
Block a user