Guest User

Untitled

a guest
Feb 26th, 2016
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.78 KB | None | 0 0
  1. while IFS= read -r path
  2. do
  3.     [ -z $path ] && continue
  4.     echo "$(date +'%d-%m-%Y %H:%M:%S') --  Creating backup for $path"
  5.     # Create or update the remote backup
  6.     ssh ${remoteUser}@$serverLocation -i sshKey/ssh mkdir -p ${remoteBasedir}/$path # Create the directory
  7.     rsync   --compress --recursive -e "ssh -i sshKey/ssh -l $remoteUser" \
  8.             --delete --links --perms \
  9.             $path $serverLocation:${remoteBasedir}/$path
  10.     rSyncStatus=$?
  11.    
  12.     [ $rSyncStatus -eq 0 ] && status="success" || status="fail"
  13.     echo "$(date +'%d-%m-%Y %H:%M:%S') --  Exit code for backup: $rSyncStatus ($status)"
  14.     echo "$(date +'%d-%m-%Y %H:%M:%S') --  ---------------"
  15.     [ $status == "fail" ] && declare -i backupResult=0 # If this backup fails, we count the overall backup process as a failure
  16. done < "$backupPathsFile"
Add Comment
Please, Sign In to add comment