温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

数据备份之–rsync

发布时间:2020-05-27 16:06:21 来源:网络 阅读:377 作者:caidui 栏目:安全技术

软件版本:rsync-3.0.9
服务器端配置
>需要安装xinetd服务

yum install xinetd -y #rhel
apt-get install xinetd -y #ubuntu

>安装

wget http://rsync.samba.org/ftp/rsync/rsync-3.0.9.tar.gzwget http://rsync.samba.org/ftp/rsync/rsync-patches-3.0.9.tar.gztar zxvf rsync-3.0.9.tar.gztar zxvf rsync-patches-3.0.9.tar.gzcd rsync-3.0.9
./configuremake && make install

1.创建配置文件

vim /etc/rsyncd.conf
; port=873uid=rootgid=root
max connections=10log file=/var/log/rsyncd.log
pid file=/var/run/rsyncd.pid
lock file=/var/run/rsyncd.lock
secrets file=/etc/rsyncd.passwd
; hosts allow=192.168.11.0/27; hosts deny=192.168.11.0/255.255.255.224timeout=600 [backdir]comment= for client backpath=/home/backdir/read only = no
;exclude=test;exclude from=/path/to/file;include from=/path/to/fileauth users=caide.me[share]comment= backup share filepath=/home/share/read only = yesauth users=caide.me

2.创建密码文件(/etc/rsyncd.passwd)

echo "caide.me:caide.me.passwd" > /etc/rsyncd.passwdchmod 600 /etc/rsyncd.passwd

3.创建xinetd监听任务(/etc/xinetd.d/xinetd_rsync)

vim /etc/xinetd.d/xinetd_rsync
# default: off# description: The rsync server is a good addition to an ftp server, as it \#       allows crc checksumming etc.service rsync{
        disable = no
        socket_type     = stream        wait            = no
        user            = root
        server          = /usr/local/bin/rsync
        server_args     = --daemon
        log_on_failure  += USERID}
service xinetd restart

–>如有需要,防火墙需开启tcp协议873端口<--

客户端配置
>安装

wget http://rsync.samba.org/ftp/rsync/rsync-3.0.9.tar.gzwget http://rsync.samba.org/ftp/rsync/rsync-patches-3.0.9.tar.gztar zxvf rsync-3.0.9.tar.gztar zxvf rsync-patches-3.0.9.tar.gzcd rsync-3.0.9
./configuremake && make install

备份-还原文件shell脚本

#!/bin/sh# 按照IP进行备份NICS=`arp -a | awk '{print $7}'`NIC=`echo $NICS |awk '{print $1}'`SERVERIP=`ifconfig $NIC | awk '/inet / {print $2}' | cut -f2 -d ":"`# directory to backupBDIR=/path/to/backdir# excludes file - this contains a wildcard pattern per line of files to excludeEXCLUDES=no_rsync.txt# the name of the backup machineBSERVER=back_server_ipif [ "$SERVERIP" = "$BSERVER" ]thenexitfi# your password on the backup serverUSERNAME=caide.meexport RSYNC_PASSWORD=caide.me.passwd########################################################################MODULE=backdirOPTS="--force --ignore-errors --delete-excluded --exclude-from=$EXCLUDES--delete -avz"export PATH=$PATH:/bin:/usr/bin:/usr/local/bin# now the actual transferrsync $OPTS $BDIR $USERNAME@$BSERVER::$MODULE/$SERVERIP  #备份# rsync $OPTS $USERNAME@$BSERVER::$MODULE/$SERVERIP $BDIR #还原


向AI问一下细节
推荐阅读:
  1. rsync复制
  2. rsync命令

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI