ScratchMonkey

Backup to external drive

Mar 5th, 2018
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.56 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. set -e
  4. set -x
  5.  
  6. LABEL=Backup201803
  7. DEVICE=/dev/disk/by-label/${LABEL}
  8. MOUNTPOINT=/mnt/${LABEL}
  9.  
  10. # first check to see if drive is present
  11.  
  12. if [ ! -b ${DEVICE} ]
  13. then
  14.         echo "external backup drive ${LABEL} not present"
  15.         exit 1
  16. fi
  17.  
  18. # mount it if needed
  19.  
  20. if [ ! -d ${MOUNTPOINT}/backup/orifice ]
  21. then
  22.         mount ${DEVICE} ${MOUNTPOINT}
  23. fi
  24.  
  25. if [ ! -d ${MOUNTPOINT}/backup/orifice ]
  26. then
  27.         echo "mount failed"
  28.         exit 1
  29. fi
  30.  
  31. # now backup to it
  32.  
  33. time rsync -av --one-file-system / /mnt/${LABEL}/backup/orifice/
Add Comment
Please, Sign In to add comment