yum 安装rsync openssh-devel
将当前主机内容推送到远程主机
[root@ftp ~]# rsync -avzP -e 'ssh -p 22' /fei/ root@192.168.1.141:/xiao/
root@192.168.1.141's password:
sending incremental file list
./
fei.txt
13 100% 0.00kB/s 0:00:00 (xfer#1, to-check=0/2)
root@192.168.1.141's password:
sending incremental file list
./
fei.txt
13 100% 0.00kB/s 0:00:00 (xfer#1, to-check=0/2)
sent 98 bytes received 34 bytes 1.70 bytes/sec
total size is 13 speedup is 0.10
total size is 13 speedup is 0.10
[root@vsftpd xiao]# ls
[root@vsftpd xiao]# ls
fei.txt
将远程主机内容拉取到当前主机
[root@vsftpd xiao]# ls
fei.txt
将远程主机内容拉取到当前主机
[root@ftp fei]# ls
[root@ftp fei]#
[root@ftp fei]#
[root@ftp fei]# rsync -avzP -e 'ssh -p 22' root@192.168.1.141:/xiao/ /fei/
root@192.168.1.141's password:
receiving incremental file list
./
fei.txt
13 100% 12.70kB/s 0:00:00 (xfer#1, to-check=0/2)
root@192.168.1.141's password:
receiving incremental file list
./
fei.txt
13 100% 12.70kB/s 0:00:00 (xfer#1, to-check=0/2)
sent 33 bytes received 103 bytes 1.55 bytes/sec
total size is 13 speedup is 0.10
[root@ftp fei]# ls
fei.txt
total size is 13 speedup is 0.10
[root@ftp fei]# ls
fei.txt
++++++++++++++++++++++++++++++++++我是无聊的分割线++++++++++++++++++++++++++++++
[root@c backup]# cat /etc/rsyncd.conf
#rsync_config_____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
##########################################
[backup]
# 使用目录
path = /backup/
# 有错误时忽略
ignore errors
# 可读可写(true或false)
read only = false
# 阻止远程列表(不让通过远程方式看服务端有啥)
list=false
# 允许IP
hosts allow = 192.168.1.0/24
# 禁止IP
hosts deny = 0.0.0.0/32
# 虚拟用户
auth users = rsync_backup
# 存放用户和密码的文件
secrets file = /etc/rsync.password
##rsync_config______end#
[root@c ~]# useradd -M -s /sbin/nologin rsync #创建rsync用户
[root@c ~]# cat /etc/passwd | grep rsync
rsync:x:500:500::/home/rsync:/sbin/nologin
[root@ ~]# cat /etc/group | grep rsync
rsync:x:500:
[root@c ~]# mkdir /backup #创建共享目录
[root@c ~]# rsync --daemon
[root@c~]# chown -R rsync /backup
[root@c~]# echo "rsync_backup:123456" >/etc/rsync.password
[root@c~]# chmod 600 /etc/rsync.password
[root@c~]# echo "rsync --daemon" >> /etc/rc.local
推送测试
[root@vsftpd ~]# which rsync
/usr/bin/rsync
[root@vsftpd ~]# echo "123456" > /etc/rsync.password
[root@vsftpd ~]# chmod 600 /etc/rsync.password
[root@vsftpd ~]# mkdir /backup
[root@vsftpd ~]# touch /backup/test
[root@vsftpd ~]# rsync -avz /backup/ rsync_backup@192.168.1.140::backup --password-file=/etc/rsync.password
sending incremental file list
./
test
/usr/bin/rsync
[root@vsftpd ~]# echo "123456" > /etc/rsync.password
[root@vsftpd ~]# chmod 600 /etc/rsync.password
[root@vsftpd ~]# mkdir /backup
[root@vsftpd ~]# touch /backup/test
[root@vsftpd ~]# rsync -avz /backup/ rsync_backup@192.168.1.140::backup --password-file=/etc/rsync.password
sending incremental file list
./
test
sent 74 bytes received 30 bytes 9.90 bytes/sec
total size is 0 speedup is 0.00
total size is 0 speedup is 0.00
[root@vsftpd ~]# rsync -avz /tmp/ rsync_backup@192.168.1.140::backup --password-file=/etc/rsync.password
sending incremental file list
./
yum.log
yum_save_tx-2018-04-21-18-028jMVH0.yumtx
.ICE-unix/
sending incremental file list
./
yum.log
yum_save_tx-2018-04-21-18-028jMVH0.yumtx
.ICE-unix/
sent 458 bytes received 53 bytes 48.67 bytes/sec
total size is 531 speedup is 1.04
total size is 531 speedup is 1.04
拉取测试
[root@vsftpd ~]# rsync -avz rsync_backup@192.168.1.140::backup /backup --password-file=/etc/rsync.password
receiving incremental file list
./
test3
test4
.ICE-unix/
receiving incremental file list
./
test3
test4
.ICE-unix/
sent 112 bytes received 260 bytes 35.43 bytes/sec
total size is 0 speedup is 0.00
total size is 0 speedup is 0.00
[root@vsftpd ~]# rsync -avz rsync_backup@192.168.1.140::backup/66.html /backup --password-file=/etc/rsync.password
receiving incremental file list
66.html
receiving incremental file list
66.html
sent 83 bytes received 136 bytes 20.86 bytes/sec
total size is 0 speedup is 0.00
[root@vsftpd ~]#
total size is 0 speedup is 0.00
[root@vsftpd ~]#
[root@vsftpd ~]# rsync -avz --exclude=7f rsync_backup@192.168.1.140::backup /backup --password-file=/etc/rsync.password
receiving incremental file list
./
8k
receiving incremental file list
./
8k
sent 95 bytes received 245 bytes 32.38 bytes/sec
total size is 0 speedup is 0.00
total size is 0 speedup is 0.00
#排除7f这个文件,增量备份其他文件
[root@vsftpd ~]# ls /backup
66.html 8k test test3 test4
[root@vsftpd ~]# ls /backup
66.html 8k test test3 test4