Linux uses SSH rsync to sync backup VPS site files and directories

Source: Internet
Author: User
Tags ssh vps rsync
This is the time to learn about the VPS backup file content, because after using the VPS all security issues need our own processing, including the security of the website files. We can choose to make regular manual backups, or we can choose to automate scheduled backups. In the old left blog has also written a few on the VPS, the site back up the article, perhaps a little long time do not know whether it is still valid, but this time as far as possible to organize a number of different backup methods, so that users have more choices of opportunities. In this article, the old left will share the use of a word SSH command, using the rsync mirror Backup tool to back up the Web site in host A to the corresponding directory in B host.

First, rsync synchronous backup preparation work

A-We need to identify the location of the site in the VPS host where our backup targets are located, such as:

/home/wwwroot/www.111cn.net/
B-Need to explicitly backup VPS directory and environment has been installed, here we can be specifically used for backup, or sync the past in case a VPS problems, and then switch IP resolution directly does not affect the site and other matters. For example, I want to back up here:
/home/wwwroot/www.111cn.net/backup/
We need to make sure that catalog files are present, and here we need to be aware that the 2 "www.111cn.net" above is the same name, but not under a VPS.
C-Backup target VPS already installed rsync tools
Because if not installed, the following script will appear "-bash:rsync:command not found" error prompts, then we need to install rsync, not all VPS are installed by default.
Yum-y Install rsync #centos环境

apt-get install-y rsync #debian环境

This allows us to complete the installation before we can proceed to the next step.

Second, the execution of a word rsync mirrored backup SSH script

The code is as follows Copy Code
Rsync-e "/usr/bin/ssh"-avzl/home/wwwroot/www.111cn.net/root@192.192.192.192:/home/wwwroot/www.111cn.net/backup/

The above 3 color labeling is required according to our actual backup directory modifications, the following IP address is our backup to the VPS IP address, according to their actual changes.

After executing the script, you will see if we agree to execute, enter Yes return, and then we need to enter the B backup VPS root password, and then automatically back up after return.

Third, the implementation of the Rsync backup process to complete

See the above results on behalf of the backup completed, a total backup to the number of file bytes can be seen.
The above is actually just a simple rsync application, mainly behind the old left to learn and apply to synchronous automatic backup. If just such a backup file is too simplistic, you might as well package the wget effect

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.