附:
# rsync - 远程shell模式和rsync守护进程模式
# rsync作为客户端,有两种工作模式,远程shell模式和rsync守护进程模式
# 远程shell模式常见语法分别如下:
# /usr/bin/rsync 是rsync命令的路径。
# -a, --archive
# This is equivalent to -rlptgoD. It is a quick way of saying you want recursion and want to preserve almost everything (with -H being a notable omission). The only exception to the above equivalence is when --files-from is specified, in which case -r is not implied.
# 等价于-rlptgoD。简言之即是想最大限度的保留所有事物(值得注意的是忽略了-H)。仅在指定了--files-from时不等价,此时不执行-r。
# -e, --rsh=COMMAND
# This option allows you to choose an alternative remote shell program to use for communication between the local and remote copies of rsync. Typically, rsync is configured to use ssh by default, but you may prefer to use rsh on a local network。
# 该选项允许选择一个远程shell应用程序用于rsync在本地和远程副本间通讯,通常,rsync默认配置成使用ssh,但是在一个本地网络中也可以使用rsh。
# /bin/ssh 是本地ssh命令的路径。
# -i 是ssh命令指定私钥的参数
# identity_file 是ssh命令使用私钥的路径
# USER 是登录用的帐户,应当和identity_file对应
# HOST 是远程的主机
# /path/to/source/ 是远程的路径
# /path/to/destination/ 是本地的路径
/usr/bin/rsync -a -e "/bin/ssh -i identity_file" USER@HOST:/path/to/source/ /path/to/destination/
# rsync守护进程模式常见语法分别如下:
# /usr/bin/rsync 是rsync命令的路径。
# -a, --archive
# This is equivalent to -rlptgoD. It is a quick way of saying you want recursion and want to preserve almost everything (with -H being a notable omission). The only exception to the above equivalence is when --files-from is specified, in which case -r is not implied.
# 等价于-rlptgoD。简言之即是想最大限度的保留所有事物(值得注意的是忽略了-H)。仅在指定了--files-from时不等价,此时不执行-r。
# -u, --update
# This forces rsync to skip any files which exist on the destination and have a modified time that is newer than the source file. (If an existing destination file has a modification time equal to the source file's, it will be updated if the sizes are different.)
# 强制rsync跳过目标上已存在而且比源文件新的任何文件。(如果一个已存在的目标文件的修改时间和源文件相等,则在尺寸不同时更新)
# -z, --compress
# With this option, rsync compresses the file data as it is sent to the destination machine, which reduces the amount of data being transmitted -- something that is useful over a slow connection.
# 使用该选项,rsync在发送到目标设备前压缩文件数据,这将减少传输文件的数量——对于慢速连接有用处
# HOST 是远程的主机
# module 是rsync守护进程中的模块名
# /path/to/destination/ 是本地的路径
/usr/bin/rsync -auz HOST::module /path/to/destination/
转自:http://blog.csdn.net/hu_zhenghui/article/details/3811100