sudo vim /etc/default/rsync
RSYNC_ENABLE=true //设置开启同步
sudo mkdir -p /etc/rsync/
//同步用户密码文件
vi /etc/rsync/rsyncd.secrets
chmod 600 /etc/rsync/rsyncd.secrets
cp /usr/share/doc/rsync/examples/rsyncd.conf /etc/
vim /etc/rsyncd.conf
# sample rsyncd.conf configuration file
# GLOBAL OPTIONS
#motd file=/etc/motd
log file=/var/log/rsyncd
# for pid file, do not use /var/run/rsync.pid if
# you are going to run rsync out of the init.d script.
# The init.d script does its own pid file handling,
# so omit the "pid file" line completely in that case.
# pid file=/var/run/rsyncd.pid
#syslog facility=daemon
#socket options=
# MODULE OPTIONS
[ftp]
comment = public archive
path = /var/www/pub
use chroot = yes
# max connections=10
lock file = /var/lock/rsyncd
# the default for read only is yes...
read only = no
list = yes
uid = root
gid = root
# exclude =
# exclude from =
# include =
# include from =
auth users = gao_rsync
secrets file = /etc/rsync/rsyncd.secrets
strict modes = yes
hosts allow = 36.41.175.249
# hosts deny =
ignore errors = no
ignore nonreadable = yes
transfer logging = no
# log format = %t: host %h (%a) %o %f (%l bytes). Total %b bytes.
timeout = 600
refuse options = checksum dry-run
dont compress = *.gz *.tgz *.zip *.z *.rpm *.deb *.iso *.bz2 *.tbz
chmod 777 /etc/rsyncd.conf
sudo rsync -avzP --delete /home/user/test.log gao_rsync@36.41.175.70::ftp --password-file=/etc/rsync/rsyncd.secrets
ls /proc/sys/fs/inotify
inotify 服务会在多文件时报观察数太少问题,应该对/proc/sys/fs/inotify/max_user_watches下的值进行修改,以便填加观察数。
chmod +x /home/tongbu/to36.41.175.70.sh
nohup bash /home/tongbu/to36.41.175.70.sh &
#!/bin/bash
src=/var/lib/docker/files
dst[0]=gao_rsync@36.41.175.70::ftp
/usr/bin/inotifywait -mr --timefmt '%d/%m/%y %H:%M' --format '%T %w%f%e' -e modify,delete,create,attrib $src | while read files
do
for i in ${dst[@]}
do
rsync -vzrtopg --delete --progress --password-file=/etc/rsync/rsyncd.secrets $src $i
echo $i
done
done
exit 0
RSYNC_ENABLE=true //设置开启同步
sudo mkdir -p /etc/rsync/
//同步用户密码文件
vi /etc/rsync/rsyncd.secrets
chmod 600 /etc/rsync/rsyncd.secrets
cp /usr/share/doc/rsync/examples/rsyncd.conf /etc/
vim /etc/rsyncd.conf
# sample rsyncd.conf configuration file
# GLOBAL OPTIONS
#motd file=/etc/motd
log file=/var/log/rsyncd
# for pid file, do not use /var/run/rsync.pid if
# you are going to run rsync out of the init.d script.
# The init.d script does its own pid file handling,
# so omit the "pid file" line completely in that case.
# pid file=/var/run/rsyncd.pid
#syslog facility=daemon
#socket options=
# MODULE OPTIONS
[ftp]
comment = public archive
path = /var/www/pub
use chroot = yes
# max connections=10
lock file = /var/lock/rsyncd
# the default for read only is yes...
read only = no
list = yes
uid = root
gid = root
# exclude =
# exclude from =
# include =
# include from =
auth users = gao_rsync
secrets file = /etc/rsync/rsyncd.secrets
strict modes = yes
hosts allow = 36.41.175.249
# hosts deny =
ignore errors = no
ignore nonreadable = yes
transfer logging = no
# log format = %t: host %h (%a) %o %f (%l bytes). Total %b bytes.
timeout = 600
refuse options = checksum dry-run
dont compress = *.gz *.tgz *.zip *.z *.rpm *.deb *.iso *.bz2 *.tbz
chmod 777 /etc/rsyncd.conf
sudo rsync -avzP --delete /home/user/test.log gao_rsync@36.41.175.70::ftp --password-file=/etc/rsync/rsyncd.secrets
ls /proc/sys/fs/inotify
inotify 服务会在多文件时报观察数太少问题,应该对/proc/sys/fs/inotify/max_user_watches下的值进行修改,以便填加观察数。
chmod +x /home/tongbu/to36.41.175.70.sh
nohup bash /home/tongbu/to36.41.175.70.sh &
#!/bin/bash
src=/var/lib/docker/files
dst[0]=gao_rsync@36.41.175.70::ftp
/usr/bin/inotifywait -mr --timefmt '%d/%m/%y %H:%M' --format '%T %w%f%e' -e modify,delete,create,attrib $src | while read files
do
for i in ${dst[@]}
do
rsync -vzrtopg --delete --progress --password-file=/etc/rsync/rsyncd.secrets $src $i
echo $i
done
done
exit 0