rysnc同步文件

Rsync(remote synchronize)是一个远程数据同步工具,可通过LAN/WAN快速同步多台主机间的文件。Rsync使用所谓的“Rsync算法”来使本地和远 程两个主机之间的文件达到同步,这个算法只传送两个文件的不同部分,而不是每次都整份传送,因此速度相当快。

1,在服务器段添加2个文件,分别是/etc/rsyncd.conf和/etc/rsyncd.passwd.
a,vi /etc/rsyncd.conf
uid=root
gid=root
max connections=4
log file=/var/log/rsyncd.log
pid file=/var/run/rsyncd.pid
lock file=/var/run/rsyncd.lock

[backup]
comment= backup arch
path=/u02/arch
read only = ralse
ignore errors
list = false
host allow = 172.20.90.32
auth users=oracle
secrets file=/etc/rsyncd.passwd

b,vi /etc/rsyncd.passwd
oracle:password
c, chmod 600 /etc/rsyncd.passwd
2,修改rsync启动方式
vi /etc/xinetd.d/rsync
把disable = yes
改为disable = no
3,启动rsync服务
service xinetd restart
4,在备份服务器新建备份脚本文件
vi backup
#!/bin/sh
# This script does backup oracle archived logfile to a rsync backup server.

# directory to backup

BDIR=/u1/backup/nxcard/arch

# excludes file - this contains a wildcard pattern per line of files to exclude
EXCLUDES=/u02/exclude
# the name or ip address of the backup machine

BSERVER=RAC1
#
PASSWD=/etc/rsyncd.passwd

#backup options
OPTS="-avzu --exclude-from=$EXCLUDES --password-file=$PASSWD"
#user name of backup
USER=oracle

# now the actual transfer
rsync $OPTS $USER@$BSERVER::backup $BDIR
5,为backup文件添加执行权限
chmod 555 backup
6,添加crontab计划项
crontab -e root
0 * * * * /u1/backup/backup

你可能感兴趣的:(rsync)