Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- ## variables
- # distant server
- dist_srv='1.1.1.1'
- # local directory for backups if distant srv is dead
- local_bck='file:///backups'
- # will the backup be local only ? (default no [0])
- is_local=0
- # distant directory for backups
- dist_bck='\\srv-services\backup\'
- # protocol for sending
- srv_proto='smb'
- # username if mandated
- srv_user=''
- # password if mandated
- srv_passwd=''
- HOME=$HOME
- ## some tests before
- # (apt-get install|yum install|emerge|...) duplicity
- if !(which duplicity); then
- echo 'Please install duplicity package'
- exit 1
- fi
- # is the distant server alive ?
- if (ping -c2 -w3 $dist_srv); then
- echo 'WARNING! distant server seems to be down or unavalaible!'
- echo 'LOCAL backups only'
- echo
- is_local=1
- fi
- ## choose correct URL for backup
- #declare -i is_local
- if [ $is_local -eq 0 ]; then
- case $srv_proto in
- smb)
- # for smb, we have to mount the share - duplicity doesn't seems to support it for now.
- mount -t cifs -o username=${srv_user},password=${srv_passwd} //${dist_srv}/${dist_bck} /home/backups
- url=${local_bck}
- duplicity ${HOME} ${url}
- ;;
- *)
- echo 'TO BE IMPLEMENTED'
- ;;
- esac
- else
- # local backup
- rsync -r -n -t -v --progress --existing -z "$HOME" "$local_bck"
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement