Rename btrfs subvolumes

Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
2024-07-03 10:18:58 +03:00
parent a960df740b
commit 2cca11bfaa
3 changed files with 17 additions and 17 deletions

View File

@@ -9,17 +9,17 @@ delete_subvolume_recursively() {
mkdir -p /mnt/btrfs
mount /dev/mapper/luks /mnt/btrfs
if [[ -e /mnt/btrfs/root ]]; then
mkdir -p /mnt/btrfs/root.bak
timestamp=$(date --date="@$(stat -c %Y /mnt/btrfs/root)" "+%Y-%m-%-d_%H:%M:%S")
mv /mnt/btrfs/root "/mnt/btrfs/root.bak/$timestamp"
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"
fi
find /mnt/btrfs/root.bak/ -maxdepth 1 -mtime +14 | while IFS= read -r i; do
find /mnt/btrfs/@.bak/ -maxdepth 1 -mtime +14 | while IFS= read -r i; do
delete_subvolume_recursively "$i"
done
btrfs subvolume create /mnt/btrfs/root
btrfs subvolume create /mnt/btrfs/@
umount /mnt/btrfs
rmdir /mnt/btrfs