In one sentence, SSH command uses rsync to synchronize and backup VPS website directory files.

888u

Last update at :2024-06-17,Edit by888u

Snail is going to learn something about VPS backup files during this time, because after using VPS, we need to deal with all security issues ourselves, including the security of website files. We can choose regular manual backups or automated scheduled backups. I have written several articles about VPS and website backup in the Snail Blog before. It may have been a while and I don’t know if it is still effective, but during this time I will try to sort out some different backup methods so that users can have more choices. In this article, Snail will share 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.

Article Directory Hide

First, rsync synchronization backup preparations

Second, execute one sentence rsync image backup SSH script

Third, execute the rsync backup process to completion

First, rsync synchronization backup preparations

A – We need to clarify the location of the website directory in the VPS host of our backup target, for example:

/home/wwwroot/laozuo.org/

B – It is necessary to make it clear that the directory and environment of the backup VPS have been installed. Here we can clarify whether it is used exclusively for backup or synchronized in case there is a problem with VPS A, and then switching IP resolution will not affect the website directly. For example, I want to backup to here:

/home/wwwroot/laozuo.org/backup/

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

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

Because if it is not installed, the error message "-bash: rsync: command not found" will appear when executing the following script. Then we need to install rsync. It is not installed by default in all VPSs. OK

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 one sentence rsync image backup SSH script

rsync -e \\”/usr/bin/ssh\\” -avzl /home/wwwroot/laozuo.org/ [email protected]192.192.192.192:/home/wwwroot/laozuo.org/backup/

The above three colors marked need to be modified according to our actual backup directory. The IP address behind is the VPS IP address we back up to, which should be modified according to our actual situation.

After executing the script, we will be asked if we agree to execute it. Enter yes and press Enter. Then we are required to enter the ROOT password of B backup VPS. After pressing Enter, it will automatically back up.

Third, execute the rsync backup process to completion

Seeing the above result means that the backup is complete. You can see how many file bytes have been backed up in total.

The above is actually just a simple rsync application. The main thing is that Snail needs to learn and apply it to synchronize automatic backup later. If it is just such a backup file, it is too simple, and it is not as effective as packaging wget.

Recommended site search: Jiangsu high defense server, website space purchase, registered cn domain name, Hong Kong server, cloud server rental, domain name purchase, Hong Kong server rental 99idc, Hong Kong server rental 99idc, Hong Kong space, virtual host evaluation network,

In one sentence, SSH command uses rsync to synchronize and backup VPS website directory files.

All copyrights belong to 888u unless special state
取消
微信二维码
微信二维码
支付宝二维码