Advertisement
alexs77

recursive btrfs snapshots

May 2nd, 2013
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.53 KB | None | 0 0
  1. SnapName=backup.`date +%Y%m%d--%H%M%S`
  2. btrfs fi show 2>/dev/null | awk '/ path / {print $NF}' | while read path; do
  3.   SafePath=`echo "$path" | tr / .`
  4.   TmpMountDir=`mktemp -d /tmp/.btrfs.mount.$SafePath.XXXXXX`
  5.   mount -t btrfs $path $TmpMountDir
  6.   (btrfs subv list -ar $TmpMountDir; btrfs subv list -a $TmpMountDir) | sort | uniq -u | while read _id Id _gen Gen _top _level Toplevel _path Path; do
  7.     btrfs subv snaps -r "$TmpMountDir/$Path" "$TmpMountDir/$Path.$SnapName"
  8.   done
  9.   umount $TmpMountDir
  10.   rmdir $TmpMountDir
  11. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement