rsync - remote synchronize是类unix系统下的数据镜像备份工具,它的特性如下:
二. 安装 服务端和客户端安装rsync yum -y install rsync 也可以源码安装 rsync下载地址:http://rsync.samba.org/ ./configure make && make install 但是需要注意的是必须在服务器A和B上都安装rsync,其中A服务器上是以服务器模式运行rsync,而B上则以客户端方式运行rsync。这样在web服务器A上运行rsync守护进程,在B上定时运行客户程序来备份web服务器A上需要备份的内容。 三. 服务端配置 cat /etc/rsyncd.conf #[globale] strict modes = yes port = 873 uid = nobody gid = nobody user chroot = no max connections = 5 #同时的最大连接数 timeout = 600 pid file = /var/run/rsyncd.pid #进程的pid存放文件位置 lock file = /var/run/rsyncd.lock #lock文件位置 log file = /var/log/rsyncd.log #日志文件位置 [testdata] #建立一个备份名,客户端通过该名称指定具体的备份位置 path=/data/test/img #备份文件存放的目录位置 ignore errors read only = no list = no hosts allow = 106.xxx.xxx.xxx #允许客户端B地址 auth users = test #允许那些用户,这里的用户test的信息存放在/etc/rsyncd.password secrets file = /etc/rsyncd.password #指定允许的用户和用户密码 建立/etc/rsyncd.password文件 cat /etc/rsyncd.password test:123456 修改防火墙策略,允许873端口(tcp/udp) iptables -A INPUT -s 106.xxx.xxx.xxx -p tcp -m state --state NEW -m tcp --dport 873 -j ACCEPT service iptables save 启动服务器端 /usr/bin/rsync --daemon --config=/etc/rsyncd/rsyncd.conf开机自启动 echo '/usr/bin/rsync --daemon --config=/etc/rsyncd/rsyncd.conf' >> /etc/rc.local 四. 客户端配置 /usr/bin/rsync -avzP --delete --progress --password-file=/etc/rsyncd.password test@服务端ip::test /data/backup/img rsync参数 -a --archive归档模式,表示以递归方式传输文件,并保持所有文件属性,等于-rlptgoD -r --recursive 对子目录以递归模式处理 -l --links 保留软链 -p --perms 保持文件权限 -t --times 保持文件时间信息 -g --group 保持文件属组信息 -o --owner 保持文件属主信息 -D --devices 保持设备文件信息 -z --compress 对备份的文件在传输时进行压缩处理 -P --partial 保留那些因故没有完全传输的文件,以是加快随后的再次传输 -v --verbose 详细模式输出 -e --rsh=COMMAND 指定替代rsh的shell程序 -u --update 仅仅进行更新,也就是跳过所有已经存在于DST,并且文件时间晚于要备份的文件。(不覆盖更新的文件) --progress 显示备份过程 --delete 是指如果服务器端删除了这一文件,那么客户端也相应把文件删除,保持真正的一致。 转载请保留固定链接: https://linuxeye.com/configuration/729.html |