Advertisement
morxa

pre-backup

Mar 5th, 2012
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.53 KB | None | 0 0
  1. #!/bin/bash
  2. mountpoint="/mnt/backup/"
  3. devicedir="/dev/cryptpool/"
  4. echo "$1" | grep -q "$mountpoint"
  5. if [ $? -ne 0 ] ; then
  6.     exit 0
  7. fi
  8. orig=$(echo "$1" | sed -e 's:^'$mountpoint'::' -e 's:/$::')
  9. full=$(echo "$1" | sed 's:/$::')
  10. if [ "$full" != "$mountpoint$orig" ];
  11. then
  12.     echo "Error!"
  13.     exit 1
  14. fi
  15. lvcreate -n "$orig"backup -s "$devicedir$orig" -l 100%FREE
  16. retlv=$?
  17. if [ $retlv -ne 0 ]; then
  18.     echo "Error creating logical volume. return value: $retlv"
  19.     exit $retlv
  20. fi
  21. mkdir -p $full
  22. mount -o ro "$devicedir$orig"backup $full
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement