rsync是開源常柄、高速的惠奸、可實現(xiàn)本地以及遠(yuǎn)程,全量以及增量的數(shù)據(jù)復(fù)制(拷貝)工具略就。
服務(wù)端配置
1.關(guān)閉防火墻
systemc stop firewalld
systemc disable firewalld
setenforce 0
2.關(guān)閉selinux
vim /etc/selinux/config
SELINUX=disabled
3.rsync服務(wù)端配置詳解(web01“ip 10.160.1.15”)
(1)rsync配置文件詳解
cat /etc/rsyncd.conf
rsync_config_______________start
uid = rsync
gid = rsync
use chroot = no
fake super = yes
max connections = 200
timeout = 600
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 = 10.160.1.0/24
hosts deny = 0.0.0.0/32
auth users = rsync_backup
secrets file = /etc/rsync.password
[date]
comment = welcome to oldboyedu backup!
path = /date/
(2)創(chuàng)建rsync目錄和用戶
mkdir /date
useradd rsync
chown -R rsync:rsync
(3)配置rsync密碼文件
cat /etc/rsync.password
rsync_backup:oldboy
chmod 600 /etc/rsync.password
4.配置rsync客戶端(web02)
配置rsync密碼認(rèn)證文件
方法一:
cat /etc/rsync.password
oldboy
chmod 600 /etc/rsync.password
方法二:
echo ' export RSYNC_PASSWORD=oldboy' >>/etc/bashrc
. /etc/bashrc
5.生產(chǎn)案例
每天晚上00點整在web服務(wù)器A(web02)上打包備份網(wǎng)站程序目錄并通過rsync命令推送到服務(wù)器B(web01)上備份保留(備份思路可以是先在本地按日期大包兄墅,然后再利用rsync推到備份服務(wù)器上)
web01腳本
cat /scripts/rsync.sh
!/bin/bash
backup conf and /etc/hosts
mkdir /date/html_(date +%F)/html_$(date +%F -d "-1day").tar.gz hosts
md5
mkdir /date/md5sum_(date +%F)/hosts_md5_$(date +%F)
rsync
rsync -avz /date/ rsync_backup@10.160.1.15::date --password-file=/etc/rsync.password
web01 定時任務(wù)
- 0 * * * /usr/bin/sh /scripts/rsync.sh &>/dev/null