add find subvol and snap a folder of subvolumes
parent
7963e13c59
commit
82dec74a7b
|
@ -71,12 +71,30 @@ echo "~ $((subvolumeFolderSize/1024/1024)) GB"
|
|||
}
|
||||
|
||||
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
|
||||
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 {} +
|
||||
}
|
||||
|
||||
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 '
|
||||
# for d do
|
||||
# btrfs subvolume show "$d" >/dev/null 2>&1 && printf "%s\n" "$d"
|
||||
|
|
Loading…
Reference in New Issue