/usr/bin/rsync -vzrtopg --delete --progress rsync@192.168.8.126::test /usr/local/share/rsync_backup --password-file=/etc/rsync.pass
20、 带exclude 参数:
把服务器上的/home/hyj/workspace/test文件夹中的内容备份到客户端的/usr/local/share/rsync_backup中,但不包括:res目录和default.properties文件:
/usr/bin/rsync -vzrtopg --delete --exclude "res/" --exclude "default.properties" --progress rsync@192.168.8.126::test /usr/local/share/rsync_backup --password-file=/etc/rsync.pass
exclude/include规则实例
Here are some exclude/include examples: --exclude "*.o" would exclude all filenames matching *.o --exclude "/foo" would exclude a file in the base directory called foo --exclude "foo/" would exclude any directory called foo. --exclude "/foobar" would exclude any file called bar two or more levels below a base directory called foo. --include "*/" --include "*.c" --exclude "*" would include all directories and C source files --include "foo/" --include "foo/bar.c" --exclude "*" would include only foo/bar.c (the foo/ directory must be explicitly included or it would be excluded by the "*")
21、 把客户端上的/home/hyj/vitest文件夹中的内容备份到服务器的/usr/local/share/rsync_backup中,在客户端执行如下命令:
/usr/bin/rsync -vzrtopg --delete --progress /home/hyj/vitest rsync@192.168.8.126::clientdata --password-file=/etc/rsync.pass
此时服务器的配置文件/etc/rsyncd.conf内容为:
uid = root gid = root hosts allow = 192.168.8.122, 192.168.8.123 #hosts deny = 0.0.0.0/32 use chroot = no max connections = 10 pid file = /var/run/rsyncd.pid lock file = /var/run/rsync.lock log file = /var/log/rsyncd.log timeout=600 [test] path = /home/hyj/workspace/test comment = rsync files ignore errors read only = yes list = no auth users = rsync secrets file = /etc/rsync.passwd # 上面的命令中,客户端的数据备份到clientdata模块中,备份到/usr/local/share/rsync_backup文件夹下,read only改为no,# # 否则会报ERROR: module is read only的错误 [clientdata] path = /usr/local/share/rsync_backup comment = rsync files ignore errors read only = no list = no auth users = rsync secrets file = /etc/rsync.passwd
定时计划备份
22、 如果执行crontab命令提示:

说明还没有为root这个账号提供crontab。执行crontab –e 创建一个crontab:

23、 编辑crontab,每两分钟备份一次:











