rsync备份服务
|
rsync服务介绍:一款实现全量及增量复制同步的软件工具
rsync服务命令简单应用(1v4的应用效果) [[email?protected] ~]# # rsync == cp效果 [[email?protected] ~]# cp -a /etc/hosts /tmp/ [[email?protected] ~]# ll /tmp/ total 4 -rw-r--r--. 1 root root 352 Jan 27 01:15 hosts [[email?protected] ~]# rsync -a /etc/sysconfig/network /tmp/ [[email?protected] ~]# ll /tmp/ total 8 rw-r--r--. 1 root root 352 Jan 27 01:15 hosts -rw-r--r-- 1 root root 31 Jan 26 18:16 network ②. rsync == scp [[email?protected] ~]# scp -rp /tmp/ 172.16.1.31:/tmp/
The authenticity of host ‘172.16.1.31 (172.16.1.31)‘ can‘t be established.
RSA key fingerprint is 5b:9b:e6:79:a9:95:4f:be:06:41:e3:bb:7a:12:ee:b4.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘172.16.1.31‘ (RSA) to the list of known hosts.
[email?protected]‘s password:
network 100% 31 0.0KB/s 00:00
hosts 100% 352 0.3KB/s 00:00
[[email?protected] ~]# ll /tmp/
total 8
-rw-r--r--. 1 root root 352 Jan 27 01:15 hosts
-rw-r--r-- 1 root root 31 Jan 26 18:16 network
[[email?protected] ~]# rsync -rp /tmp/ 172.16.1.31:/tmp/
[email?protected]‘s password:
说明: ③ rsync == rm [[email?protected] ~]# mkdir /null
[[email?protected] ~]# rsync --delete /null/ /tmp/
rsync: --delete does not work without -r or -d.
rsync error: syntax or usage error (code 1) at main.c(1422) [client=3.0.6]
[[email?protected] ~]#
[[email?protected] ~]# rsync -r --delete /null/ /tmp/
[[email?protected] ~]# ll /tmp/
total 0
④ rsync == ls [[email?protected] ~]# ls /etc/hosts
/etc/hosts
[[email?protected] ~]# ls -l /etc/hosts
-rw-r--r--. 2 root root 352 Jan 27 01:15 /etc/hosts
[[email?protected] ~]# rsync /etc/hosts
-rw-r--r-- 352 2018/01/27 01:15:59 hosts
rsync软件工作方式 [[email?protected] ~]# rsync -a /etc/hosts /tmp/ok.txt [[email?protected] ~]# ll /tmp/ok.txt -rw-r--r-- 1 root root 352 Jan 27 01:15 /tmp/ok.txt ②. 远程数据备份方式 Access via remote shell:
Pull: rsync [OPTION...] [[email?protected]]HOST:SRC... [DEST]
Push: rsync [OPTION...] SRC... [[email?protected]]HOST:DEST
pull方式语法说明: push方式语法说明: ③. 守护进程传输模式 Access via rsync daemon:
Pull: rsync [OPTION...] [[email?protected]]HOST::SRC... [DEST]
rsync [OPTION...] rsync://[[email?protected]]HOST[:PORT]/SRC... [DEST]
Push: rsync [OPTION...] SRC... [[email?protected]]HOST::DEST
rsync [OPTION...] SRC... rsync://[[email?protected]]HOST[:PORT]/DEST
pull:rsync [OPTION...] [[email?protected]]HOST::SRC... [DEST]
[[email?protected]]HOST:: --- 指定远程连接的认证用户 SRC --- 指定相应的模块信息 [DEST] --- 将远程数据保存到本地的路径信息 Push: rsync [OPTION...] SRC... [[email?protected]]HOST::DEST [[email?protected]]HOST:: --- 指定远程连接的认证用户 SRC --- 指定本地要进行推送的数据信息 [DEST] --- 远程进行保存数据的模块信息 rsync守护进程部署流程 [[email?protected] ~]# rpm -qa rsync
rsync-3.0.6-12.el6.x86_64
第二里程:编写配置文件 vim /etc/rsyncd.conf
#rsync_config
#created by HQ at 2017
##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
ignore errors
read only = false
list = false
hosts allow = 172.16.1.0/24
hosts deny = 0.0.0.0/32
auth users = rsync_backup
secrets file = /etc/rsync.password
[backup]
comment = "backup dir by oldboy"
path = /backup
read only = true
[nfs]
comment = "backup dir by oldboy"
path = /nfs
第三个里程:创建备份目录管理用户 第四个里程:创建备份目录 mkdir /backup
chown -R rsync.rsync /backup
第五个里程:创建认证文件 echo "rsync_backup:oldboy123" >>/etc/rsync.password
chmod 600 /etc/rsync.password
第六个里程:启动rsync服务 2)客户端部署流程 [[email?protected] ~]# rpm -qa rsync
rsync-3.0.6-12.el6.x86_64
第二个里程:创建认证密码文件 echo "oldboy123" >>/etc/rsync.password
chmod 600 /etc/rsync.password
第三个里程:进行数据备份测试 [[email?protected] tmp]# rsync -avz /etc/hosts [email?protected]::backup --password-file=/etc/rsync.password
sending incremental file list
hosts
sent 189 bytes received 27 bytes 432.00 bytes/sec
total size is 352 speedup is 1.63
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
