add find subvol and snap a folder of subvolumes

master
David Kebler 2023-12-16 08:27:37 -08:00
parent 7963e13c59
commit 82dec74a7b
1 changed files with 21 additions and 3 deletions

View File

@ -71,12 +71,30 @@ echo "~ $((subvolumeFolderSize/1024/1024)) GB"
} }
find_subvolumes() { find_subvolumes() {
sudo /bin/find $1 -maxdepth $2 -type d -exec sh -c ' dir=${1:-.}
dep=${2:-1}
sudo /bin/find "$dir" -maxdepth $dep -type d -exec bash -c '
for d do for d do
sudo btrfs subvolume show "$d" >/dev/null 2>&1 && printf "%s\n" "$d" subv=$(basename $d)
sudo btrfs subvolume show "$d" >/dev/null 2>&1 && printf "%s\n" "$subv"
done' find-sh {} + done' find-sh {} +
} }
folder_snapshot() {
for sv in $(find_subvolumes $1 1); do
if [[ -d $2/$sv ]]; then
echo snapshot $sv already exists in $2. You must manually delete target snapshots!
else
sudo btrfs sub snap $1/$sv $2
fi
done
}
# sudo find / -type d -exec sh -c ' # sudo find / -type d -exec sh -c '
# for d do # for d do
# btrfs subvolume show "$d" >/dev/null 2>&1 && printf "%s\n" "$d" # btrfs subvolume show "$d" >/dev/null 2>&1 && printf "%s\n" "$d"