Advertisement
Guest User

Untitled

a guest
May 28th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/sh
  2.  
  3. ## variables
  4. # distant server
  5. dist_srv='1.1.1.1'
  6. # local directory for backups if distant srv is dead
  7. local_bck='file:///backups'
  8. # will the backup be local only ? (default no [0])
  9. is_local=0
  10. # distant directory for backups
  11. dist_bck='\\srv-services\backup\'
  12. # protocol for sending
  13. srv_proto='smb'
  14. # username if mandated
  15. srv_user=''
  16. # password if mandated
  17. srv_passwd=''
  18. HOME=$HOME
  19.  
  20.  
  21. ## some tests before
  22. # (apt-get install|yum install|emerge|...) duplicity
  23. if !(which duplicity); then
  24.   echo 'Please install duplicity package'
  25.  exit 1
  26. fi
  27. # is the distant server alive ?
  28. if (ping -c2 -w3 $dist_srv); then
  29.   echo 'WARNING! distant server seems to be down or unavalaible!'
  30.  echo 'LOCAL backups only'
  31.  echo
  32.   is_local=1
  33. fi
  34.  
  35. ## choose correct URL for backup
  36. #declare -i is_local
  37. if [ $is_local -eq 0 ]; then
  38.   case $srv_proto in
  39.     smb)
  40.       # for smb, we have to mount the share - duplicity doesn't seems to support it for now.
  41.      mount -t cifs -o username=${srv_user},password=${srv_passwd} //${dist_srv}/${dist_bck} /home/backups
  42.       url=${local_bck}
  43.       duplicity ${HOME} ${url}
  44.       ;;  
  45.     *)  
  46.       echo 'TO BE IMPLEMENTED'
  47.      ;;  
  48.   esac
  49. else
  50.   # local backup
  51.   rsync -r -n -t -v --progress --existing -z "$HOME" "$local_bck"
  52. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement