Rsync is a data mirroring Backup tool under Unix-like systems--remote sync. is a fast incremental backup tool remote Sync, which supports local replication or synchronizes with other SSH and rsync hosts.
By building rsync server and client, it is easy to solve the problem of file synchronization in the test environment and production environment, and the synchronization process is completely automated, which avoids the error transmission or leakage phenomenon of manual uploading files.
Now let's look at the setup process together.
Production environment host (rsync service side) settings
1. Configure rsyncd.conf Files
Vi/etc/rsyncd.conf
The settings are as follows:
[web]
Uid=www
Gid=www
Auth users = Web
Secrets file =/etc/rsyncd.pass
Path =/home/htdocs/web
2. Set Access password
Vi/etc/rsyncd.pass
The settings are as follows:
web:123456
Access password line corresponds to a user, in the form of user name: password
3. Change the permissions of the password file
chmod 600/etc/rsyncd.pass
Test environment Host (rsync client) configuration
1. Set Access password
Vi/etc/rsync/web.pas
The settings are as follows:
123456
The name of the password file for the Rsync client is the same as the user name
2. Change the permissions of the password file
chmod 600/etc/rsync/web.pas
3. To set the synchronization time to ignore the file
Vi/etc/rsync/exclude_web.conf
The contents of the exclude_web.conf file are as follows:
. SVN
. log
. ini
After the Rsync server and client settings are set, you can test the success of the settings on the client by executing the following command:
Rsync-avz--chmod=u=rwx,g=rx,o=r--progress--exclude-from=/etc/rsync/exclude_web.conf--password-file=/etc/rsync/ web.pas/home/htdocs/web/web@192.168.0.1::web/