btrfs-snap 342 B

123456789101112131415161718192021
  1. #!/bin/sh
  2. usage () {
  3. cat <<EOF>&2
  4. Usage: ${0##*/} SUBVOLUMES...
  5. Snapshot all Btrfs SUBVOLUMES to a read-only '.snapshots/SUBVOLUME/DATE'.
  6. EOF
  7. }
  8. if [ $# -eq 0 ]; then
  9. usage
  10. exit 1
  11. fi
  12. for i; do
  13. root=$(findmnt -n --output TARGET -T "$i")
  14. sudo btrfs subvolume snapshot -r "$i" $root/.snapshots/"$(basename "$i")"/$(date +%F_%R:%S)
  15. done