For example, the/www directory on the Web server is backed up to the rsync server.
rsync:192.168.1.10 web:192.168.1.11
1 Configuring the Rsync server
Create a System user Useradd-s/sbin/nologin-m rsync
Create Directory Mkdir/backup
Chown-r rsync.rsync/backup/
vim/etc/rsyncd.conf Copy the content below
UID = rsync
GID = rsync
Use chroot = no
Max connections = 200
Timeout = 300
PID file =/var/run/rsyncd.pid
Lock file =/var/run/rsync.lock
Log file =/var/log/rsyncd.log
[Backup] (module, can be arbitrary, but the Web server connection should be noted (in the script:: Backup). )
Path =/tmp/backup/(important)
Ignore errors
Read Only = False
List = False
Hosts allow = 192.168.1.0/24 (specify reachable IP)
Hosts Deny = 0.0.0.0/32 (other deny)
Auth users = Renkun (authentication user)
Secrets file =/etc/rsync.password
To create a user-connected file
Create user Renkun Password 1234
Useradd renkun-p 1234
Create a password file
Vim/etc/rsync.password
renkun:1234
Change permissions (required)
chmod 600/etc/rsync.password
Start the daemon process
Rsync--daemon
View Port 873 Open
Netstat-tnl
Web server-side configuration
Configure password file
Vim/etc/rsync.password
1234
Create an automatic upload script
vim/zd.sh
#!bin/bash
I= "' Date +%y-%m-%d-%h-%m '"
#echo "$i"
tar-zcvf/tmp/$i. tar.gz/www
rsync-avz/tmp/$i. tar.gz [Email protected]::backup--password-file=/etc/rsync.password
rm-rf/tmp/$i. tar.gz
Configuring Crontab Periodic uploads
Crontab-e
30 23 * * *. /zd.sh (minutes, hours, days, months, weeks: 23:30 every day. The test can be uploaded per minute using * * * * * * *
Complete
This article is from the "Itcain" blog, make sure to keep this source http://521kun.blog.51cto.com/9397206/1773526
Rsync +crontab implementing scheduled backup files