Centos6.5 rsync synchronous backup
This chapter mainly explains the realization of fast, safe and efficient remote backup.
Experimental environment: server A 192.168.1.10 client B 192.168.1.20
First, install rsync yum-y install rsync*
Create a new configuration file vi / etc/rsyncd.conf
Uid = nobody
Gid = nobody
Use chroot = yes
Address = 192.168.1.10
Port 873
Log file = / var/log/rsyncd.log
Pid file = / var/run/rsyncd.pid
Hosts allow = 192.168.1.0 Compact 24
[yy]
Path = / var/www/html
Comment = ccccccccccccc
Read only = yes
Dont compress = * .gz * .bz2
Auth users = bin
Secrets file = / etc/rsyncd_users.db
Note: if you use anonymous synchronization, just remove the auth users and secrets file configuration records.
Second, create a password authentication file vi / etc/rsyncd_users.db
Bin:123
Save exit
Modify password file permissions chmod 600 / etc/rsyncd_users.db
Third, start rsync rsync-- daemon ps-ef | grep rsync to view the process.
If you want to end the process kill process number kill
1. Use rsync local backup to back up the file / etc/fastab to / tmp
Rsync-rl / etc/fastab / tmp/
2. To use the client for remote backup, first configure the server firewall iptables-I INPUT-p tcp-- dport 873-j ACCEPT
Service iptables save Save Firewall
Fourth, client configuration
1. Create the test directory mkdir / rsync
two。 Synchronize rsync shared directories
# rsync bin@192.168.1.10::yy / / Browse sharing
Vim / root/rsync_pass / / set password file
123 / / only need to write the login user password, which should be consistent with the password set by the server
Chmod 60000 / root/rsync_pass / / error will be reported if permissions are not modified
Rsync-az-- password-file=/root/rsync_pass bin@192.168.1.10::yy / rsync / / synchronization
3. Put rsync into crontab scheduled tasks and synchronize once a day
# crontab-e
0 5 * / usr/bin/rsync-a-password-file=/root/rsync_pass bin@192.168.1.10::yy / rsync