Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 29th, 2012  |  syntax: Bash  |  size: 0.42 KB  |  hits: 23  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/bin/sh
  2. # reliable file transfer
  3.  
  4. # try rsync for x times
  5. i=0
  6. max_restarts=10
  7. f=0
  8.  
  9. while [ "$i" -le "$max_restarts" ]; do
  10.   i=$((i+1))
  11.   echo "$i. start of rsync"
  12.   if rsync -avzP --rsh='/usr/local/bin/sshpass -p password ssh -l username' \
  13.      ip.address:/var/www/ /cygdrive/o/backups/ .; then
  14.      f=1
  15.   fi
  16. done
  17.  
  18. if [ "$f" -eq 0 ]; then
  19.   echo "rsync failed after $i times"
  20. else
  21.   echo "rsync worked"
  22. fi