Lao Zuo has known that Qiniu Cloud storage can be used to back up our website on Linux vps for a long time. At least I don't have the ability to write backup scripts myself, and I don't have time to learn in the future. But I can use the existing online tutorials to integrate, modify and reorganize. In fact, I was going to write this article a few months ago, but none of the script tutorials I saw on the Internet were successfully executed according to the instructions. Either the results of the script execution were different from those in the tutorial, or important parts were omitted.

For example, our VPS system needs to support Python version 2.7, but many online tutorials have taught users to find Python upgrade methods themselves, but this upgrade method is not easy to find, so in“ Step 9 Upgrade the Python version of CentOS5 system to 2.7 "In, Lao Zuo prepared this article first in order to complete VPS to achieve automatic scheduled backup of Qiniu cloud storage. Therefore, the backup effect can be achieved through two reinstallation VPS tests. Now I am writing this tutorial and reinstalling VPS, which can ensure the complete record of the tutorial (so as to ensure the integrity of Lao Zuo's blog tutorial).
Installation environment:
A - Lao Zuo's environment in this tutorial is the Linux centos5 32-bit system, which needs to be upgraded to Python 2.7 ;
B - You need a Qiniu Cloud storage space, which can be applied for free“ Free Qiniu Cloud storage 10G space and traffic application activation tutorial attached purpose "。
C - The website environment is the one click installation package of LNMP (it doesn't matter whether the environment is used or not, as long as the path corresponds to the backup later)
We need to prepare in advance for specific preparations, because the new VPS system I use to ensure the integrity of the tutorial requires testing in a new environment. The following is mainly to share the whole process of specific seven cow backup.
Step 1: Download the backup script and install it
wget -O backuptoqiniu.zip https://www.dropbox.com/s/6xjm9vngm48rlit/backuptoqiniu.zip unzip backuptoqiniu.zip cd backuptoqiniu python setup.py install
Step 2. Configuration Backuptoqiniu.sh file
We can backuptoqiniu.sh Download the file to the local location to modify the required configuration, or directly configure the VI online.
#Backup name, used to mark BACKUP_ NAME="qiniu-backup" #The backup directory should be separated by a space BACKUP_ SRC="/home/wwwroot/" #MySQL host address MYSQL_ SERVER="localhost" #MySQL user name MYSQL_ USER="root" #MySQL password MYSQL_ PASS="mysqlpassword" #MySQL backup database. Multiple databases should be separated by spaces MYSQL_ DBS="dbname" #The temporary storage directory of backup files does not need to be changed generally BACKUP_ DIR="/tmp/backuptoqiniu" #Backup file compression password to ensure the security of the compressed package BACKUP_ FILE_ PASSWD="laozuo.org" ##Backup configuration information End## ##Configuration information of 7N## #The storage space corresponds to the folder we created on Qiniu QINIU_ BUCKET="laozuoorg" #ACCESS_ KEY QINIU_ ACCESS_ KEY="<YOUR_APP_ACCESS_KEY>" #SECRET_ KEY QINIU_ SECRET_ KEY="<YOUR_APP_SECRET_KEY>" ##End##
The above is a script segment that needs to be modified into our own account information. The upper part is our VPS file path, database link, and our backup compression package encryption settings; The next part is about the key link settings of the 7-Bull store. We need to find the AccessKey/SecretKey in the 7-Bull background and fill it in to QINIU_ ACCESS_ KEY and QINIU_ SECRET_ KEY,QINIU_ BUCKET is our directory folder in Qiniu.
Step 3: Set permissions and test backup
We need to set the backuptoqiniu.sh permission and debug the backup
chmod +x backuptoqiniu.sh ./backuptoqiniu.sh
Here is a problem to pay attention to. If we test and execute the backup script for the first time, we will see such an interface.

We can see that the ZIP script is not recognized. It is strange that it can be decompressed before. Why can't it be compressed here? Since it is not easy to use, see this article to reinstall the ZIP environment( Solve the unzip file of Linux VPS installation )。 Then we will see such a successful interface.

After the backup test, we can see the files backed up in the folder of the background interface of 7N Storage.
Step 4. Set scheduled automatic backup
crontab -e 0 2 * * 0/bin/bash/root/backuptoqiniu/backuptoqiniu.sh # Add this script
Add a scheduled task to automatically back up every Sunday at 2:00 a.m.
So far, using Qiniu Cloud Storage to automatically back up our VPS website is a success. If we prefer to use other backup methods, we can also use Automatic backup of Dropbox , and we automatically Backup to FTP space Even if you are afraid of trouble, you can also backup manually on a regular basis.
Scan the code to follow the official account
Get more news about webmaster circle!
Entrepreneurship, operation and new knowledge