Data backup-rsync
Software version: rsync-3.0.9
Server-side configuration
Need to install xinetd service
Yum install xinetd-y # rhelapt-get install xinetd-y # ubuntu
Installation
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. Create a profile
Vim / etc/rsyncd.conf; port=873uid=rootgid=rootmax connections=10log file=/var/log/rsyncd.logpid file=/var/run/rsyncd.pidlock file=/var/run/rsyncd.locksecrets 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
two。 Create a password file (/ etc/rsyncd.passwd)
Echo "caide.me:caide.me.passwd" > / etc/rsyncd.passwdchmod 600 / etc/rsyncd.passwd
3. Create xinetd snooping task (/ etc/xinetd.d/xinetd_rsync)
Vim / etc/xinetd.d/xinetd_rsync# default: off# description: The rsync server isa 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
-> if necessary, the firewall needs to open port 873 of tcp protocol to install
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
Backup-restore file shell script
#! / bin/sh# backup NICS= `arp-an according to IP | 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 # backup # rsync $OPTS $USERNAME@$BSERVER::$MODULE/$SERVERIP $BDIR # restore