Focus on cloud service provider activities
Notes on website operation and maintenance

One sentence SSH command uses rsync to synchronously backup VPS website directory files

Lao Zuo is going to learn something about VPS backup files these days, because after using VPS, we need to deal with all security issues ourselves, including the security of website files. We can choose to back up manually or automatically. Previously on Laozuo Blog I have also written several articles about VPS and website backup in. I may not know whether they are still effective for a long time, but I try to sort out some different backup methods during this time, so that users can have multiple choices. In this article, Lao Zuo will share that he uses the one sentence SSH command and the rsync image backup tool to back up the website files in host A to the corresponding directory in host B.

First, preparations for rsync synchronous backup

A - It is necessary to specify the location of the website directory in the VPS host of our backup target, such as:

 /home/wwwroot/laozuo.org/

B - It is necessary to specify that the directory and environment for backing up VPS have been installed. Here we can specify whether to use it exclusively for backup or to synchronize it in case of problems with VPS A, and then switch IP resolution directly without affecting the website. For example, I want to back up here:

 /home/wwwroot/laozuo.org/backup/

We need to ensure that the directory files exist first. Here we need to note that the above two "laozuo. org" are of the same name, but not under one VPS.

C - The rsync tool has been installed in the backup target VPS

Because if it is not installed, an error message "- bash: rsync: command not found" will appear when the following script is executed. We need to install rsync. Not all VPSs are installed by default.

 Yum - y install rsync # centos environment Apt get install - yrsync # debian environment

In this way, we can complete the installation before proceeding to the next step.

Second, execute the one sentence rsync image backup SSH script

rsync -e "/usr/bin/ssh" -avzl /home/wwwroot/laozuo.org/ root@ 192.192.192.192 : /home/wwwroot/laozuo.org/backup/

The above three colors indicate that it needs to be modified according to our actual backup directory, and the following IP address is the VPS IP address we backed up to, according to our own actual modification.

 Rsync backup execution

After executing the script, we will be asked whether we agree to execute it. Enter yes and press Enter. Then we need to enter the ROOT password of B Backup VPS. After pressing Enter, the backup will be performed automatically.

Third, execute the rsync backup process to the end

 The rsync backup is complete

The above results indicate that the backup is complete. You can see how many file bytes are backed up.

The above is just a simple rsync application, mainly because Laozuo needs to learn and apply it to synchronous automatic backup. If only such backup files are too simple, it is better to package wget.

Vote for you
Domain name host preferential information push QQ group: six hundred and twenty-seven million seven hundred and seventy-five thousand four hundred and seventy-seven Get preferential promotion from merchants.
Like( zero )
Do not reprint without permission: Lao Zuo's Notes » One sentence SSH command uses rsync to synchronously backup VPS website directory files


Scan the code to follow the official account

Get more news about webmaster circle!
Entrepreneurship, operation and new knowledge