Add btrbk

Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
2025-06-02 11:40:37 +01:00
parent 0481bc2785
commit 1f44a8b6bc
14 changed files with 59 additions and 112 deletions

View File

@@ -129,7 +129,10 @@ in
"directory"
];
default = "none";
description = "Whether to create the file or directory in persistence if it does not exist.";
description = ''
Whether to create the file or directory
in persistence if it does not exist.
'';
};
};
}

View File

@@ -13,11 +13,22 @@ mount "$DEVICE" /mnt/btrfs
if [[ -e /mnt/btrfs/@ ]]; then
mkdir -p /mnt/btrfs/@.bak
timestamp=$(date --date="@$(stat -c %Y /mnt/btrfs/@)" "+%Y-%m-%d_%H:%M:%S")
mv /mnt/btrfs/@ "/mnt/btrfs/@.bak/$timestamp"
timestamp=$(date --date="@$(stat -c %Y /mnt/btrfs/@)" "+%Y%m%dT%H%M")
base="@.$timestamp"
target="/mnt/btrfs/@.bak/$base"
if [[ -e "$target" ]]; then
i=1
while [[ -e "/mnt/btrfs/@.bak/${base}_$i" ]]; do
(( i++ ))
done
target="/mnt/btrfs/@.bak/${base}_$i"
fi
mv /mnt/btrfs/@ "$target"
fi
find /mnt/btrfs/@.bak/ -maxdepth 1 -mtime +14 | while IFS= read -r i; do
find /mnt/btrfs/@.bak/ -maxdepth 1 -mtime +7 | while IFS= read -r i; do
delete_subvolume_recursively "$i"
done