The method of implementing timing synchronous Incremental backup file in Linux in rsync

Source: Internet
Author: User
Tags chmod vps rsync

First, rsync synchronous backup preparation work

We need to download 2 packages: rsync server-side profile (VPS data section)/Rsync Client Profile (VPS Backup host)

Second, configure the server-side VPS

We upload the server-side rsync profile of the Rsync-server.zip download to the/etc directory, and we need to modify several locations before uploading:

A-rsyncd.conf the 7th line of address = 11.11.11.11 to modify IP addresses to our server-side IP address
B-rsyncd.conf 20th Modify hosts allow=22.22.22.22 modify to our client IP address
C-rsyncd.conf Line 35th Modify Path =/home/wwwroot/Modify the directory we need to sync
D-Modify the username and password in the Rsyncd.secrets file (user name needs to be consistent with the following E, password free), and then grant 600 permissions in SSH
The code is as follows Copy Code
chmod 600/etc/rsyncd/rsyncd.secrets

E-rsyncd.conf Line 38th, auth users = Loong, the following Loong username needs to be the same as the user name set in D above

Third, set up server-side run rsync

The code is as follows Copy Code
/usr/bin/rsync--daemon--config=/etc/rsyncd/rsyncd.conf

Set up the client configuration file

Download the Rsync-root.zip file, modify the file and upload it to the root directory

A-Set the password in the/root/pass file as the client root password and also require authorization 600 permissions
The code is as follows Copy Code
chmod 600/root/root/pass
B-Set the script path in the/root/rs.sh and need to maintain consistency with the server side
The code is as follows Copy Code
Rsync-avzp--delete--password-file=/root/pass laozuoserver@111.111.111.111::vpsmmhome/home/wwwroot/111cn.net/
#laozuoserver为服务器端/etc/rsyncd/rsyncd.secrets user name is consistent
#111.111.111.111 represents the server-side IP address
Customizing the user name #vpsmmhome为/etc/rsyncd/rsyncd.conf
#/home/wwwroot/111cn.net/for a site directory that needs to be backed up synchronously
C-Set rs.sh permissions
The code is as follows Copy Code
chmod +x/root/rs.sh
Test backups and scheduled backups

The execution of SH rs.sh can be implemented by manual backup Now, execution requires us to enter the/root/pass password before we can execute

We certainly don't need a manual backup, we need to execute the backup script regularly (enter CRONTAB-E and then add the following line).
The code is as follows Copy Code
*/1 * * */root/rs.sh
Note: 30 minutes per hour automatically sync once, this time we can set ourselves, you can also set a day to back up.
Old left in the course of writing the test has been successful once, and timed settings to ensure that this article is complete. Rsync This backup is timed to increase the backup, if the file does not change is not changed, will change the file to maintain consistent with the client, the same we can also set up the database backup, so as to ensure the synchronization of the file, once the client VPS problems, We only need to switch parsing to ensure that the site can not be affected.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.