您的位置:首页 > 运维架构 > Linux

CentOS 6.3 Rsync文件同步

2013-10-23 23:43 274 查看
一、服务端配置
1.安装
yum
install rsync xinetd

2.编辑配置文件

在/etc目录下创建一个rsyncd的目录
mkdir
/etc/rsyncd
创建rsyncd.conf
,这是rsync服务器的配置文件
touch
/etc/rsyncd/rsyncd.conf
创建rsyncd.secrets
,这是用户密码文件
touch
/etc/rsyncd/rsyncd.secrets
为了密码的安全性,把权限设为600
chmod 600
/etc/rsyncd/rsyncd.secrets
创建rsyncd.motd文件,这是定义服务器信息的文件
touch
/etc/rsyncd/rsyncd.motd

syncd.conf文件内容:

pid file
=/var/run/rsyncd.pid
port=873
address=192.168.1.250
#uid = nobody
#gid = nobody
uid=root
gid=root
use chroot=yes
read only=yes

#limit access to private LANs
hosts allow=192.168.1.0/255.255.255.0
hosts deny=*

max connections=5
motd file =/etc/rsyncd/rsyncd.motd

#This will give you a separate log file
#log file = /var/log/rsync.log
#This will log every file transferred - up to 85,000+ per
user, per sync
#transfer logging = yes

log format=%t %a %m %f %b
syslog facility=local3
timeout =300

[ftphome]
path=/opt/ftp/
list=yes
#ignore errors
auth users =sunny
secrets file =/etc/rsyncd/rsyncd.secrets
comment =ftphome
exclude =upload/

[svn]
path =/opt/svn
list=no
#ignore errors
comment = svn
auth users =sunny
secrets file = /etc/rsyncd/rsyncd.secrets

密码文件:/etc/rsyncd/rsyncd.secrets的内容
user:password

rsyncd.motd 文件;

#定义rysnc
服务器信息,也就是客户端登录显示的信

+++++++++++++++++++++++++++

+ welcome rsync 2013
+

+++++++++++++++++++++++++++

启动rsync服务:
/usr/bin/rsync --daemon
--config=/etc/rsyncd/rsyncd.conf

客户端配置:
1.安装rsync
2.执行同步
rsync -vazu
--progress user@192.168.1.250::ftp
/home/sunny/rsync/ftp
3.客户端自动同步
crontab -e

加入如下代码:
10 0 * * * rsync
-avzP --delete
--password-file=rsync.password
user@192.168.1.250::ftp
/home/sunny/rsync/ftp
表示每天0点10分执行同步

附windows局域网备份同步脚本
#mysql数据库备份

mysqldump
-uroot -p123456789 -R store >
E:\bak\�te:~0,10%store.sql
del
e:\bak\store.zip

#压缩

c:\zip.exe -j e:/bak/store.zip
e:/bak/�te:~0,10%store.sql

if exist
"c:\lock.db" exit
ping -n 1
127.0.0.1>lock.db
net use y: \\192.168.1.20\d$
"12345" /user:"admin"

xcopy /e /d
/y /c e:\bak\file\* y:\bak\file\
xcopy /e /d
/y /c e:\bak\store.zip y:\bak\sql\
ping -n 1
127.0.0.1>null
del c:\lock.db
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: