rsync简明教程

----------- rsync 简明教程 ----------------

@auther: kanpiaoxue

Date time: 2011/10/14 12:57:14

---------- [example] ----------------------

[purpose]

192.168.123.54 rsync server

192.168.123.16 rsync client

client transfer the data to server.

[server setting setup]

进入到 123.54,进行服务器端配置。

#vim /etc/xinetd.d/rsync

把 disable = yes 修改为 disable = no

#/etc/init.d/xinetd restart

#rsync --daemon      (启动rsync 的守护进程。server端需要开启)

#vim /etc/rsyncd.conf (创建或者修改rsync.conf文件)

内容如下:

#--------------------- start

uid = root

gid = root

use chroot = no

max connections = 10

pid file = /var/run/rsyncd.pid

lock file = /var/run/rsync.lock

log file = /var/log/rsyncd.log

[WEBDIR]

path=/usr/local/rsync/

comment= bi webdir backup

read only=no

use chroot=no

strict modes = no

transfer logging=yes

ignore errors=yes

auth users = rsync

secrets file = /etc/rsyncd.secrets

#--------------------- end

多文件配置

#vim /etc/rsyncd.conf (创建或者修改rsyncd.conf文件)

内容如下:

#--------------------- start

uid = root

gid = root

use chroot = no

max connections = 10

pid file = /var/run/rsyncd.pid

lock file = /var/run/rsync.lock

log file = /var/log/rsyncd.log

[MAILMARKETINGUPLOADFOLDER]

path=/webdir/tomcat50/webapps/www/report2/mailMarketingUploadFolder

comment= bi webdir backup

read only=no

use chroot=no

strict modes = no

transfer logging=yes

ignore errors=yes

auth users = rsync

secrets file = /etc/rsyncd.secrets

[UPLOAD]

path=/webdir/tomcat50/webapps/www/report2/upload

comment= bi webdir backup

read only=no

use chroot=no

strict modes = no

transfer logging=yes

ignore errors=yes

auth users = rsync

secrets file = /etc/rsyncd.secrets

[UPLOADIMAGE]

path=/webdir/tomcat50/webapps/www/report2/uploadImage

comment= bi webdir backup

read only=no

use chroot=no

strict modes = no

transfer logging=yes

ignore errors=yes

auth users = rsync

secrets file = /etc/rsyncd.secrets

[BIRT_REPORTS]

path=/webdir/tomcat50/webapps/www/birt_reports

comment= bi birt reports backup

read only=no

use chroot=no

strict modes = no

transfer logging=yes

ignore errors=yes

auth users = rsync

secrets file = /etc/rsyncd.secrets

#--------------------- end

创建密码文件: 

#vim /etc/rsyncd.secrets 内容为: rsync:123456

#chomd 600 /etc/rsyncd.secrets (修改权限,注意:密码文件的权限必须是 600)

[client setting setup]

创建密码文件:

#vim /etc/rsyncd.secrets 内容为: 123456

#chmod 600 /etc/rsyncd.secrets (修改权限,注意:密码文件的权限必须是 600)

client 不需要进行额外的配置,直接运行命令就可以。如下:

rsync -av /usr/local/rsync/ --password-file=/etc/rsync.secrets [email protected]::WEBDIR/

【注意】

client端的密码文件里面仅仅是密码,如上面的例子:123456

server端的密码文件里面是用户名和密码,格式如下:rsync:123456

还有密码文件的权限必须是 600

unexpected tag 3 [sender]

rsync error: error in rsync protocol data stream (code 12) at io.c(828) [sender=2.6.8]

网上说,rsync的2.6.8版本有个BUG,进行多模块同步时,报错。需要进行升级到3.0以上的版本。

rsync升级为最新版本

rsync3.0.8安装

rsync 3.X采用的是incremental file list,与原来的 2.X相比,现在是一边列表一边备份(添加或删除)。这对于大量文件的备份操作来说,无疑节省了很多时间。实测发现,rsync 3.0.4备份时占用的内存大约时4M,跟一个apache进程占用的内存差不多

一、安装rsync3.0.8

1、 卸载rsync(系统一般会默认安装rsync)

# rpm -qa |grep rsync

# rpm -e rsync-2.6.8-3.1

2、 安装新版rsync

# wget http://www.samba.org/ftp/rsync/src/rsync-3.0.8.tar.gz

# tar -zxvf rsync-3.0.8

# cd rsync-3.0.8

# ./configure

# make

# make install

如果运行 rsync 找不到。执行 whereis rsync 找到目录。

在 /usr/bin/ 下面创建软连接  ln -s /usr/local/rsync/rsync /usr/bin/rsync

猜你喜欢

转载自kanpiaoxue.iteye.com/blog/1667062