rsync Remote Sync Tool
1 Configuring the Rsync source Server (http://rsync.samba.org/)
(1) Setting up the configuration file
Vim/etc/rsyncd.conf
UID = nobody//Specifies the user who runs the program
GID = nobody//Specifies the group to run the program
Use chroot = yes//imprisoned in the source directory, means that only access to the directory I specified does not allow access to other directories, similar to VSFTPD's imprisonment
Address = 192.168.1.20//Specify the location of the listener
Port 873//Specify ports for listening
Log file =/var/log/rsyncd.log//Specify the location where the log files are stored
PID file =/var/run/rsyncd.pid//Specify the location of the process file
The hosts allow = 192.168.1.0/24//Specifies the address that can be accessed, where it is possible to write the IP address of the public network if it is necessary to implement geo-disaster preparedness, which can be mapped through the router.
[WWW]//Specify the name of the share
Path =/var/www/html//actual directory of source directory
Comment = dcoument Root of web.lzg.com//description information of this module
Read Only = yes (NO)//directory is read-only (readable and writable)
Dont compress =. gz. bz2. zip. Z. rar//File types that are not compressed two times during the transfer process.
Auth users = backuper//Authorized Backup User
Secrets file =/etc/rsyncdusers.db//Specify the location of data files for account information
(2) Create a data file for the backup account
Vim/etc/rsyncdusers.db
backuper:123.com//user and password, no need to establish the same name System user
chmod 600/etc/rsyncd_users.db
Rsync–daemon
Netstat–anput | grep rsync
2 Configuring the Client for validation
Rsync-avz [Email protected]::www/myweb****
3 Create password file auto-sync
Vim/etc/server.pass
123.com
chmod 600/etc/server.pass
Rsync–avz–delete--password-file=/etc/server.pass [Email protected]::www/myweb
4 Configuring Inotify+rsync Real-time synchronization
To adjust the inotify kernel parameters:
Vim/etc/sysctl.conf
Fs.inotify.max_queued_events = 16384
Fs.inotify.max_user_instances = 1024
Fs.inotify.max_user_watches = 1048576
Sysctl–p
Installing Inotify-tools
Script startup when writing triggers
Mkdir/sh
vim/sh/inotify_rsync.sh
#!/bin/bash
inotify= "Inotifywait-mrq-e modify,create,move,delete,attrib/myweb/"
rsync= "Rsync-azh--delete--password-file=/etc/server.pass/myweb/[email protected]::www]
$INOTIFY | While read DIRECTORY EVENT FILE
Do
$RSYNC
Done
Run the script
On the server
Chmod–r 777/var/www/html
Verify
rsync Remote Sync Tool