yum -y install rsync
vim /etc/rsyncd.conf
- transfer logging = yes
- log file = /var/log/rsyncd.log
- pid file = /var/run/rsyncd.pid
- lock file = /var/run/rsync.lock
- uid = nobody
- gid = nobody
- use chroot = yes
- ignore errors
- read only = no
- [data]
- comment = web content
- path = /home #配置data所指向的path
- auth users = root #允许的操作用户
- secrets file = /etc/rsyncd.secrets #配置客户端的用户密码
- host allow = 192.168.1.247/255.255.255.255 #允许访问的主机
- list = false
- fake super = yes
vim /etc/rsyncd.secrets
root:123456
chmod 600 /etc/rsyncd.secret
mkdir /home/appdatachmod -R 777 /home/appdatachown -R nobody:nobody /home/appdata
rsync --daemon
yum -y install rsync
echo "abcd@1234" >> /etc/rsync.pass && chmod 600 /etc/rsync.pass
/usr/bin/rsync -avz --delete --password-file=/etc/rsync.pass /home/appdata root@192.168.1.248::data
-a 参数,相当于 -rlptgoD ( -r 是递归 -l 是链接文件,意思是拷贝链接文件; -p 表示保持文件原有权限;-t 保持文件原有时间; -g 保持文件原有用户组; -o 保持文件原有属主; -D 相当于块设备文件);-z 传输时压缩;-P 传输进度;-v 传输时的进度等信息;--delete 删除操作--exclude 忽略文件或目录
yum -y install wget
yum -y install gcc gcc-c++
wget --no-check-certificate https://jaist.dl.sourceforge.net/project/inotify-tools/inotify-tools/3.13/inotify-tools-3.13.tar.gz
tar -zxf inotify-tools-3.13.tar.gz
cd inotify-tools-3.13/
./configure
make
make install
inotifywait
- #!/bin/bash
- src=/home/xiongan
- inotifywait -mrq --timefmt '%d/%m/%y %H:%M' --format '%T %w%f%e' -e close_write,delete,create,attrib $src | while read file;
- do
- /usr/bin/rsync -avz --delete --password-file=/etc/rsync.pass /home/appdata root@192.168.1.248::data > /dev/null 2>&1
- echo "${file} was rsynced" >>/var/log/rsync.log 2>&1
- done
nohup bash inotify_back.sh &