Rsync锅炉板脚本

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Rsync锅炉板脚本相关的知识,希望对你有一定的参考价值。

Great script found on http://www.scrounge.org/linux/rsync.html. Useful for creating boilerplate backup scripts
  1. #!/bin/sh
  2.  
  3. # Simple rsync "driver" script. (Uses SSH as the transport layer.)
  4. # http://www.scrounge.org/linux/rsync.html
  5.  
  6. # Demonstrates how to use rsync to back up a directory tree from a local
  7. # machine to a remote machine. Then re-run the script, as needed, to keep
  8. # the two machines "in sync." It only copies new or changed files and ignores
  9. # identical files.
  10.  
  11. # Destination host machine name
  12. DEST="smpent"
  13.  
  14. # User that rsync will connect as
  15. # Are you sure that you want to run as root, though?
  16. USER="root"
  17.  
  18. # Directory to copy from on the source machine.
  19. BACKDIR="/root/bin/"
  20.  
  21. # Directory to copy to on the destination machine.
  22. DESTDIR="/root/bin/"
  23.  
  24. # excludes file - Contains wildcard patterns of files to exclude.
  25. # i.e., *~, *.bak, etc. One "pattern" per line.
  26. # You must create this file.
  27. # EXCLUDES=/root/bin/excludes
  28.  
  29. # Options.
  30. # -n Don't do any copying, but display what rsync *would* copy. For testing.
  31. # -a Archive. Mainly propogate file permissions, ownership, timestamp, etc.
  32. # -u Update. Don't copy file if file on destination is newer.
  33. # -v Verbose -vv More verbose. -vvv Even more verbose.
  34. # See man rsync for other options.
  35.  
  36. # For testing. Only displays what rsync *would* do and does no actual copying.
  37. OPTS="-n -vv -u -a --rsh=ssh --exclude-from=$EXCLUDES --stats --progress"
  38. # Does copy, but still gives a verbose display of what it is doing
  39. #OPTS="-v -u -a --rsh=ssh --exclude-from=$EXCLUDES --stats"
  40. # Copies and does no display at all.
  41. #OPTS="--archive --update --rsh=ssh --exclude-from=$EXCLUDES --quiet"
  42.  
  43. # May be needed if run by cron?
  44. export PATH=$PATH:/bin:/usr/bin:/usr/local/bin
  45.  
  46. # Only run rsync if $DEST responds.
  47. VAR=`ping -s 1 -c 1 $DEST > /dev/null; echo $?`
  48. if [ $VAR -eq 0 ]; then
  49. rsync $OPTS $BACKDIR $USER@$DEST:$DESTDIR
  50. else
  51. echo "Cannot connect to $DEST."
  52. fi

以上是关于Rsync锅炉板脚本的主要内容,如果未能解决你的问题,请参考以下文章

sql 游标的锅炉板模板

锅炉基础板

Jetpack导航到一个共同的目的地

移动椭圆的板绘图代码

分享一个生产环境中利用SVN上线代码的脚本

智慧锅炉物联网云平台方案