Advertisement
st4ck

Backup con Patch incrementale

Feb 12th, 2012
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.59 KB | None | 0 0
  1. #!/usr/local/bin/bash
  2.  
  3. DIR_FROM=x/
  4. DIR_TO=$1
  5. DATA=`date "+%Y%m%d%H%M.%S"`
  6.  
  7.  
  8. echo "Avvio del backup..."
  9. for i in $(ls $DIR_FROM); do # scorro tutti i file
  10.  if [[ -f $DIR_TO/$i ]]; then # controllo se ci sia gia' un bk
  11.   if [[ ! -e $DIR_TO/$DATA ]]; then # controllo esist. dir
  12.    mkdir $DIR_TO/$DATA
  13.   fi
  14.   diff $DIR_FROM/$i $DIR_TO/$i > $DIR_TO/$DATA/$i # salvo le diff
  15.  fi
  16.  
  17.  cp -r $DIR_FROM/$i $DIR_TO/ # copia del file
  18. done
  19.  
  20. echo "Backup salvato in $DIR_TO"
  21.  
  22. if [[ -e $DIR_TO/$DATA ]]; then
  23. echo "Differenze con i file gia' presenti nella directory di backup in
  24. $DIR_TO/$DATA/"
  25. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement