rsync + inotify 实时备份
2016-04-01 14:27
274 查看
rsync配置步骤
服务器端
1. 安装rsync
yum install rsync
2. 修改配置文件
vim /etc/rsyncd.conf #默认不存在需要自己创建
##############################
uid=rsync
gid=rsync
use chroot =no
max connections=200
timeout=600
pid file=/var/run/rsyncd.pid
lock file =/var/run/rsyncd.lock
log file =/var/log/rysncd.log
[zq]
path=/zq
ignore errors
read only=no
list =no
hosts allow=192.168.1.0/24
auth user=zq
secrets file=/etc/web.passwd
3. 创建登陆用户和密码
echo zq:123456 >/etc/web.passwd
客户端
1. 创建密码文件
echo 123456 >/etc/web.passwd
2.安装inotify-tools
wget http://120.52.73.47/tenet.dl.sourceforge.net/project/inotify-tools/inotify-tools/3.13/inotify-tools-3.13.tar.gz tar xf inotify-tools-3.13.tar.gz
cd inotify-tools-3.13
./configure --prefix=/usr/local/inotify-tools/
make && make install
3. 创建监控监控和复制脚本
####inotify脚本####
#!/bin/sh
src=/backup
des=zq
rsync_passwd=/etc/web.passwd
ip=192.168.1.127
user=zq
cd ${src}
/usr/local/inotify-tools/bin/inotifywait -mrq --format '%w%f' -e modify,create,delete,attrib,close_write,move ./ |while read line
do
rsync -avzR --timeout 100 --password-file=${rsync_passwd} $line ${user}@${ip}::${des} &>/dev/null
done
4. 设置inotify脚本执行权限:
chmod a+x /rsync.sh
5. 把脚本加入到开机自动启动文件
echo "/root/inotify.sh &">> /etc/rc.local
完成
服务器端
1. 安装rsync
yum install rsync
2. 修改配置文件
vim /etc/rsyncd.conf #默认不存在需要自己创建
##############################
uid=rsync
gid=rsync
use chroot =no
max connections=200
timeout=600
pid file=/var/run/rsyncd.pid
lock file =/var/run/rsyncd.lock
log file =/var/log/rysncd.log
[zq]
path=/zq
ignore errors
read only=no
list =no
hosts allow=192.168.1.0/24
auth user=zq
secrets file=/etc/web.passwd
3. 创建登陆用户和密码
echo zq:123456 >/etc/web.passwd
客户端
1. 创建密码文件
echo 123456 >/etc/web.passwd
2.安装inotify-tools
wget http://120.52.73.47/tenet.dl.sourceforge.net/project/inotify-tools/inotify-tools/3.13/inotify-tools-3.13.tar.gz tar xf inotify-tools-3.13.tar.gz
cd inotify-tools-3.13
./configure --prefix=/usr/local/inotify-tools/
make && make install
3. 创建监控监控和复制脚本
####inotify脚本####
#!/bin/sh
src=/backup
des=zq
rsync_passwd=/etc/web.passwd
ip=192.168.1.127
user=zq
cd ${src}
/usr/local/inotify-tools/bin/inotifywait -mrq --format '%w%f' -e modify,create,delete,attrib,close_write,move ./ |while read line
do
rsync -avzR --timeout 100 --password-file=${rsync_passwd} $line ${user}@${ip}::${des} &>/dev/null
done
4. 设置inotify脚本执行权限:
chmod a+x /rsync.sh
5. 把脚本加入到开机自动启动文件
echo "/root/inotify.sh &">> /etc/rc.local
完成
相关文章推荐
- 使用 rsync 复制大文件的一些误解
- 如何在使用 scp 命令时递归地排除文件
- rsync ssh 数据同步分析
- rsync详解之exclude排除文件
- rsync结合find技巧分享
- rsync 数据同步使用详解
- 用rsync实现windows与linux文件同步的方法
- rsync命令排除文件和文件夹(exclude-from)
- Windows rsync服务器备份配置实例
- window系统的Rsync同步实战分析第1/2页
- 使用RSYNC在服务器间镜像或者备份目录和文件
- 利用rsync自动备份 完全配置方法 增加了ip限制
- Linux 用cp和rsync同步文件时跳过指定目录的方法
- rsync 同步错误 cwrsync rsync error rsync error: some files/attrs were not transferred 解决方法
- 用rsync对网站进行镜像备份实现步骤
- rsync中文手册之使用rsync实现网站镜像和备份linux第1/3页
- Python中使用Inotify监控文件实例
- 使用rsync同步网路备份第1/2页
- 使用rsync来实现文件同步
- rsync相对于其他同步工具的优缺点介绍