SHARE
TWEET

Sincro

mirkop1988 Sep 7th, 2011 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. # Server per la connessione
  4. server="localhost"
  5. # Utente per la connessione ssh
  6. user="mirko"
  7. # Porta per la connessione ssh
  8. port="22"
  9. # Opzioni per la sincronizzazione di unison
  10. # -auto         automatically accept default (nonconflicting) actions
  11. # -group        synchronize group attributes
  12. # -maxerrors n  maximum number of errors before a directory transfer is aborted
  13. # -owner        synchronize owner
  14. # -retry n      re-try failed synchronizations N times (text ui only)
  15. # -times        synchronize modification times
  16. boptions="-auto -group -retry 3 -owner -times"
  17.  
  18. # Crea la directory e il file di log
  19. mkdir -p $HOME/.rsyncremote
  20. logfile=$HOME/.rsyncremote/"`date +%d%m%y%H%M%S`.log"
  21. touch $logfile
  22. chmod 744 $logfile
  23.  
  24. #Verifica la disponibilità di unison
  25. if which unison > /dev/null; then
  26.         # Prova a pingare il server
  27.         ping -c 1 $server 1>/dev/null
  28.         # Se il server √® raggiungibile
  29.         if [ $? == "0" ]; then
  30.                 #Testa connessione e presenza di unison sul server
  31.                 if ssh -p $port $user@$server unison -version > /dev/null; then
  32.                         #Sincronizza
  33.                         unison dirprova ssh://$user@$server:$port/backup -logfile $logfile -terse $boptions
  34.                 fi
  35.         fi
  36. fi
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top