Last update at :2024-06-17,Edit by888u
In the previous article "SSH command uses rsync to synchronize backup of VPS website directory files" in the previous article is just a simple RSYNC function application, the powerful RSYNC is not only such a simple function. In view of Snail's limited capabilities and technology, search the powerful network resource library to see if you can learn and apply the upgraded application functions of RSYNC. I saw Xiaoye's article about RSYNC incremental backup, so Snail also studied and sorted it out to see if it was completely possible to achieve scheduled synchronization incremental backup.
First, RSYNC synchronization backup preparations
We need to download 2 file packages first: RSYNC server configuration file (VPS data part)/RSYNC client configuration file (VPS backup host)
Client: https://soft.laozuo.org/backup/rsync-root.zip
Server side: https://soft.laozuo.org/backup/rsync-server.zip
Second, configure server-side VPS
We upload the server-side RSYNC configuration file downloaded from rsync-server.zip to the /etc directory. Before uploading, several locations need to be modified:
A – Address = 11.11.11.11 in line 7 of rsyncd.conf changes the IP address to our server IP address
B -rsyncd.conf line 20 changes hosts allow=22.22.22.22 to the IP address of our client
C -rsyncd.conf line 35 changes path = /home/wwwroot/ to the directory we need to synchronize
D – Modify the username and password in the rsyncd.secrets file (the username needs to be consistent with E below, the password is optional), and then grant 600 permissions in SSH
chmod 600 /etc/rsyncd/rsyncd.secrets
E -rsyncd.conf line 38, auth users = loong, the subsequent loong username needs to be consistent with the username set in D above
Third, set up the server to run rsync
/usr/bin/rsync –daemon –config=/etc/rsyncd/rsyncd.conf
Fourth, set 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 to the client ROOT password, and also need to authorize 600 permissions
chmod 600 /root/root/pass
B – Set the script path in /root/rs.sh, which needs to be consistent with the server side
rsync -avzP –delete –password-file=/root/pass [email protected]::vpsmmhome /home/wwwroot/laozuo.org/
#laozuoserver is the same user name as the server-side /etc/rsyncd/rsyncd.secrets
#111.111.111.111 represents the IP address of the server
#vpsmmhome is the customized user name in /etc/rsyncd/rsyncd.conf
#/home/wwwroot/laozuo.org/ is the website directory that needs to be synchronized and backed up
C – Set rs.sh permissions
chmod +x /root/rs.sh
Fifth, test backup and scheduled backup
Executing sh rs.sh can realize the test and manual backup now. When executing, we need to enter the password of /root/pass before executing
We definitely don’t need manual backup, we need to execute the backup script regularly (enter crontab -e and add the following line).
30 */1 * * * /root/rs.sh
Note: Automatically synchronize every 30 minutes every hour. We can set this time ourselves, and you can also set up a backup once a day.
Snail has been successfully tested once when writing the tutorial, and the timing settings ensure that this article is complete. The backup of RSYNC is a regular incremental backup. If the file has not changed, it will not change. Changed files will be changed to keep them consistent with the client. Similarly, we can also set up a database backup to ensure file synchronization. Once the client If there is a problem with the client VPS, we only need to switch the resolution to ensure that the website is not affected.
Recommended site searches: icp registration query network, qq proxy server ip, US PHP host, registration query, space rental dual-line server hosting, .net space, virtual host provider, server Hong Kong, website registration,
发表评论