wget https://download.samba.org/pub/rsync/src/rsync-3.2.3.tar.gz
tar -zxvf rsync-3.2.3.tar.gz
cd rsync-3.2.3
./configure --prefix=/usr/local/rsync --disable-lz4 --disable-xxhash --without-included-zlib --disable-zstd
阿里开放端口:873
服务端:
配置文件;
vim /etc/rsyncd.conf
写入如下:
# /etc/rsyncd: configuration file for rsync daemon mode
# See rsyncd.conf man page for more options.
# configuration example:
uid = root
gid = root
use chroot = yes
max connections = 4
hosts allow = 123.233.233.133
# pid file = /var/run/rsyncd.pid
# exclude = lost+found/
# transfer logging = yes
# timeout = 900
# ignore nonreadable = yes
# dont compress = *.gz *.tgz *.zip *.z *.Z *.rpm *.deb *.bz2
[synAccount]
path = /web/home/www.phppc.com/
comment = ftp export are
read only = yes
exclude = logs/
auth users = root
secrets file = /etc/rsyncd.pass
list = no
密码文件:
vim /etc/rsyncd.pass
内容:
root:123456
客户端:
vim /etc/rsyncd.conf
输入:
# /etc/rsyncd: configuration file for rsync daemon mode
# See rsyncd.conf man page for more options.
# configuration example:
:# uid = root
# gid = root
# use chroot = yes
# max connections = 4
pid file = /var/run/rsyncd.pid
# exclude = lost+found/
# transfer logging = yes
# timeout = 900
# ignore nonreadable = yes
# dont compress = *.gz *.tgz *.zip *.z *.Z *.rpm *.deb *.bz2
# [ftp]
# path = /home/ftp
# comment = ftp export area
密码:
vim /etc/rsyncd.pass
里面输入:123456
执行:
/usr/bin/rsync -avzP --backup --password-file=/etc/rsyncd.pass root@123.123.123.123::synAccount /www/www.phppc.com/
启动:
/usr/local/rsync/bin/rsync --daemon
关闭:
ps -ef|grep rsync|grep -v grep|awk '{print $2}'|xargs kill -9
自动执行;
vim rsyncd.sh
#!/bin/bash
/usr/bin/rsync -avzP --backup --password-file=/etc/rsyncd.pass root@123.123.123::synAccount /www/www.phppc.com/
crontab -e
0,30 * * * * /www/rsyncd.sh