This article is about how to secure a backup, here is how the master server pushes the data for backup.
One, backup server configuration rsync file vi/etc/rsyncd.conf
#工作中指定用户 (can not be specified as 0) uid = 0gid = 0# is equivalent to a black hole. Error locating use Chroot = no# How many clients are simultaneously transmitting files max connections = 200# Timeout Time timeout = 300# process number file PID fil E =/var/run/rsyncd.pid# log file Lock file =/var/run/rsync.lock# logfile log file =/var/log/rsyncd.log# Module Start # module name random up (can be multiple) [ Backup] #需要备份的目录path =/backup# indicates error ignored error ignore errors# indicates network permissions writable (local control is really writable) Read Only = false# set IP here or let not synchronize list = false# Specify the allowed network segment hosts allow = 192.168.1.0/24# The address of the Reject link, which indicates that there are no rejections. Hosts Deny = 0.0.0.0/32# things (by default) #虚拟用户auth users = rsync_backup# password files for virtual users Secrets file =/etc/rsync.password
Second, the backup server configures the virtual user's password file
[Email protected]/]# echo "rsync_backup:123456" >/etc/rsync.password[[email protected]/]# cat/etc/ rsync.passwordrsync_backup:123456 #注: Rsync_backup for Virtual user, 123456 for this virtual user's password [[email protected]/]# chmod 600/etc/ Rsync.password #为密码文件提权 for added safety
Third, the master server configures the virtual user password and tests
[[email protected] ~]# echo "123456" >/etc/rsync.password[[email protected] ~]# cat /etc/ rsync.password123456 #注意: Here just write the password, remember. [[email protected] ~]# chmod 600 /etc/rsync.password[[email protected] ~]#  LL /ETC/RSYNC.PASSWORD-RW------- 1 root root 7 4 Month 22 14:32 /etc/rsync.password[[email protected] ~]# echo "Hello itstyle" >test.txt[[email protected] ~]# cat test.txthello itstyle[[email protected] ~]# rsync -avz test.txt [email protected]::backup --password-file=/etc/rsync.passwordsending incremental file listtest.txtsent 82 bytes received 27 bytes 72.67 bytes/sectotal size is 13 speedup is 0.12
Iv. Writing scripts
VI rsync_push.sh
#!/bin/bashrsync-az/home/tomcat8 [Email Protected]::backup--password-file=/etc/rsync.password
Original address:http://www.linuxprobe.com/linux-rsync-backup.html
How to implement file backup under Linux