sany_ok

rsync

Nov 11th, 2014
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.42 KB | None | 0 0
  1. #=====begin of copyright notice=====
  2. copyright()
  3. {
  4.         echo -e "
  5.  
  6.        THE AULIX_UTILS FOR DEBIAN AND CENTOS \n
  7.        The AUTHOR of this file is Alexander Borisovich Prokopyev, Kurgan, Russia \n
  8.        More info can be found at the AUTHOR's website: http://www.aulix.com/resume \n
  9.        Contact: alexander.prokopyev at aulix dot com \n
  10.        
  11.        Copyright (c) Alexander Prokopyev, 2006-2014 \n
  12.  
  13.        All materials contained in this file are protected by copyright law. \n
  14.        Nobody except the AUTHOR may alter or remove this copyright notice from copies of the content. \n
  15.        
  16.        The AUTHOR allows to use this content under AGPL v3 license:
  17.        http://opensource.org/licenses/agpl-v3.html
  18.  
  19.        ";
  20. }
  21.  
  22. copyright;
  23. #=====end of copyright notice=====
  24.  
  25. OperationType=$1;
  26. Source="$2";
  27. Destination="$3";
  28. Options=${@:4:20} # For example --delete --fake-super --compress --progress --omit-dir-times, etc
  29.  
  30. #if test -z $SSH_SERVER_PORT; then
  31. #       SSH_SERVER_PORT=22;
  32. #fi
  33.  
  34. RSync()
  35. {
  36.         ionice -c 3 rsync --archive --one-file-system --hard-links --acls --xattrs --numeric-ids --progress -e 'ssh -c arcfour,aes256-cbc,aes256-ctr' ${@:3:20} "$1" "$2"
  37. }
  38.  
  39. RSyncCompare()
  40. {
  41.     RSync --dry-run --delete --itemize-changes --verbose ${@:3:20} "$1" "$2"
  42. }
  43.  
  44. echo "=== Backup of [$Source] =>>> [$Destination] started at `date` ==="
  45.  
  46. case $OperationType in
  47.         ( system )
  48.             RSync "$Source" "$Destination" --checksum --exclude-from=/utils/sys_dirs.txt $Options
  49.             #--no-t
  50.         ;;
  51.         ( make_sys_dirs )
  52.                 cat /utils/sys_dirs.txt | /utils/text/for_each_line.sh "mkdir -p" .;
  53.         ;;
  54.         ( data )
  55.                 RSync "$Source" "$Destination" --inplace --partial $Options
  56.         ;;
  57.         ( data_ntfs )
  58.                 RSync "$Source" "$Destination" --inplace --partial --no-p --no-o --no-g --no-A $Options
  59.         ;;
  60.         ( compare_strict )
  61.                 RSyncCompare "$Source" "$Destination" --checksum --no-t $Options
  62.         ;;
  63.         ( compare )
  64.                 RSyncCompare "$Source" "$Destination" $Options
  65.         ;;
  66.         (*)
  67.                 echo "Option $1 is unknown. Please use on of the following: system, data, compare or compare_strict."
  68.                 exit 1
  69.         ;;
  70. esac
  71.  
  72. echo -e "=== Backup of [$Source] to [$Destination] completed at `date` ===";
  73.  
  74. # echo; cat /utils/fs/rsync.txt; echo;
Advertisement
Add Comment
Please, Sign In to add comment