rsync的客户端向服务端发送文件,发送文件到服务端::backup_8_114这个模块下,但是发送不出去
[root@localhost opt]# rsync --delete -avz /opt/dojsa rsync_backup@192.168.8.109::backup_8_114 --password-file=/etc/rsync.password
sending incremental file list
ERROR: module is read only
rsync error: syntax or usage error (code 1) at main.c(1142) [Receiver=3.2.3]
配置文件rsync服务端如下:
[root@localhost ~]# cat /etc/rsyncd.conf
#rsync_config_______________start
#created by jin 01:23 2019-06-09
#Email:3128743705@qq.com
##rsyncd.conf start##
uid = rsync
gid = rsync
use chroot = no
max connections = 200
timeout = 300
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
log file = /var/log/rsyncd.log #这个是 rsync 的 log 文件,比较有用
[backup]
path = /backup/
ignore errors
read only = false
list = false
hosts allow = 192.168.8.0/24
hosts deny = 0.0.0.0/32
auth users = rsync_backup
secrets file = /etc/rsyncd/rsync.password
[backup_8_114]
path = /backup/192.168.8.114
#rsync_config_______________end
————————————————
解决方案:
上次文章中的配置文件中加read only = false
[root@localhost 192.168.8.114]# cat /etc/rsyncd.conf
#rsync_config_______________start
#created by jin 01:23 2019-06-09
#Email:3128743705@qq.com
##rsyncd.conf start##
uid = rsync
gid = rsync
use chroot = no
max connections = 200
timeout = 300
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
log file = /var/log/rsyncd.log #这个是 rsync 的 log 文件,比较有用
[backup]
path = /backup/
ignore errors
read only = false
list = false
hosts allow = 192.168.8.0/24
hosts deny = 0.0.0.0/32
auth users = rsync_backup
secrets file = /etc/rsyncd/rsync.password
[backup_8_114]
path = /backup/192.168.8.114
read only = false
#rsync_config_______________end
[root@localhost ~]# rsync --delete -avz /opt/ rsync_backup@192.168.8.109::backup_8_114 --password-file=/etc/rsync.password
sending incremental file list
deleting abc/jinwaner
deleting abc/
deleting .ssh/
deleting odks
deleting anaconda-ks.cfg
deleting .viminfo
deleting .tcshrc
deleting .lesshst
deleting .cshrc
deleting .bashrc
deleting .bash_profile
deleting .bash_logout
deleting .bash_history
./
dojsa
sent 140 bytes received 212 bytes 704.00 bytes/sec
total size is 7 speedup is 0.02
在客户端下载inotify并写脚本
[root@localhost ~]# cat /etc/rsync.sh
#!/bin/bash
/usr/bin/inotifywait -mrq --format '%w%f' -e create,close_write,delete /root/ |while read file
do
cd /root/ && rsync -az --delete /root/
rsync_backup@192.168.8.xxx::backup_8_114 --password-file=/etc/rsync.password
done
测试:
rsync客户端在/root目录下创建文件
在服务端在这个模块下backup_8_114查看新增文件
[root@localhost ~]# ll
总用量 12
drwxr-xr-x 2 root root 22 12月 16 18:31 abc
-rw-------. 1 root root 1066 12月 14 17:02 anaconda-ks.cfg
-rw-r--r-- 1 root root 20 12月 16 18:10 kk
-rwxr-xr-x. 1 root root 22 12月 14 17:54 odks
[root@localhost ~]# vi dd
[root@localhost ~]# ll
总用量 16
drwxr-xr-x 2 root root 22 12月 16 18:31 abc
-rw-------. 1 root root 1066 12月 14 17:02 anaconda-ks.cfg
-rw-r--r-- 1 root root 30 12月 16 18:51 dd
-rw-r--r-- 1 root root 20 12月 16 18:10 kk
-rwxr-xr-x. 1 root root 22 12月 14 17:54 odks
[root@localhost 192.168.8.114]# ll
总用量 16
drwxr-xr-x. 2 rsync rsync 22 12月 16 18:31 abc
-rw-------. 1 rsync rsync 1066 12月 14 17:02 anaconda-ks.cfg
-rw-r--r--. 1 rsync rsync 30 12月 16 18:51 dd
-rw-r--r--. 1 rsync rsync 20 12月 16 18:10 kk
-rwxr-xr-x. 1 rsync rsync 22 12月 14 17:54 odks