Last update at :2024-06-15,Edit by888u
Snail has long known that Qiniu Cloud Storage can be used to back up our website on Linux vps. If I were to write my own backup script, at least for now, I wouldn’t have the ability to do so. I guess I won’t have time to learn in the future, but I can use the Internet Existing tutorials will be integrated, and imperfect ones will be modified and organized. In fact, I planned to write this article a few months ago, but the script tutorials I saw on the Internet were not successfully executed. Either the result of the script execution was different from what the tutorial said, or important parts were omitted.
For example, our VPS system needs to support Python version 2.7, but many tutorials on the Internet mention it at once and let users find the Python upgrade method by themselves. However, this upgrade method is not easy to find, so in \\"9 Steps to upgrade CentOS5 system Python version to 2.7\\", Snail prepared this article first, in order to complete the VPS implementation of automatic scheduled backup of Qiniu Cloud Storage. Therefore, the backup effect can be achieved by reinstalling the VPS twice to test. Now I am writing this tutorial and reinstalling the VPS again, so as to ensure the complete record of the tutorial (so as to ensure the completeness of the Snail Blog tutorial).
Installation environment:
A – The environment in this Snail tutorial is linux centos5 32-bit system, and the system needs to be upgraded to Python 2.7 first;
B – You need a Qiniu cloud storage space, you can apply for it for free\\"Free Qiniu cloud storage 10G space and traffic application activation tutorial with purpose\\".
C – The website environment uses the LNMP one-click installation package (the specific environment does not matter, as long as the path corresponds to the backup later)
We need to prepare specific preparations in advance, because I am using a brand new VPS system to ensure the integrity of the tutorial, and it needs to be tested in a new environment. The following is mainly about sharing the entire process of Qiniu backup.
Article Directory Hide
The first step is to download the Qiniu backup script and install it
The second step is to configure the backuptoqiniu.sh file
Step 3, set permissions and test backup
Step 4: Set up scheduled automatic backup
Step one, download and install Qiniu backup script
wget -O backuptoqiniu.zip https://www.dropbox.com/s/6xjm9vngm48rlit/backuptoqiniu.zipunzip backuptoqiniu.zipcd backuptoqiniupon setup.py install
The second step, configure the backuptoqiniu.sh file
We can download the backuptoqiniu.sh file locally to modify the required configuration, or we can directly configure the VI online.
# Backup name, used to mark BACKUP_NAME=\\\"qiniu-backup\\\"# Backup directory, please separate multiple with spaces BACKUP_SRC=\\\"/home/wwwroot/\\\"# Mysql host address MYSQL_SERVER= \\\"localhost\\\"# Mysql username MYSQL_USER=\\\"root\\\"# Mysql password MYSQL_PASS=\\\"mysqlpassword\\\"# Mysql backup database, please separate multiple with spaces MYSQL_DBS= \\\"dbname\\\"# The directory where backup files are temporarily stored. Generally, there is no need to change BACKUP_DIR=\\\"/tmp/backuptoqiniu\\\"# The backup file compression password ensures the security of the compressed package BACKUP_FILE_PASSWD=\\\" laozuo.org\\\"## Backup configuration informationEnd #### Qiniu configuration information###The storage space corresponds to the folder we created on Qiniu QINIU_BUCKET=\\\"laozuoorg\\\"#ACCESS_KEYQINIU_ACCESS_KEY= \\\"\\\"#SECRET_KEYQINIU_SECRET_KEY=\\\"\\\"## Qiniu configuration informationEnd ##The above is an interception of the main script segments that need to be modified into our own account information. The upper part is the file path of our VPS, the link to the database, and the encryption settings of our backup compressed package; the lower part is the more critical Qiniu storage For link settings, we need to find the AccessKey/SecretKey in our account key in the Qiniu backend and fill in QINIU_ACCESS_KEY and QINIU_SECRET_KEY. QINIU_BUCKET is the directory folder we opened in Qiniu.
Step 3, set permissions and test backup
We need to set backuptoqiniu.sh permissions and debug backup
chmod +x backuptoqiniu.sh./backuptoqiniu.shThere is an issue that needs to be noted here. 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 decompression was possible before, but why is the compression not working here? Since it is not easy to use, read this article to reinstall the ZIP environment (solve Linux VPS installation UNZIP component decompression file) . Then we will see a successful interface like this when we execute it.
After executing the backup test, we can see the backed up files in the Qiniu storage background interface folder.
Step 4: Set up scheduled automatic backup crontab -e0 2 * * 0 /bin/bash /root/backuptoqiniu/backuptoqiniu.sh #Add this script
Add a scheduled task to automatically back up every Sunday at 2 am.
At this point, using Qiniu Cloud Storage to automatically back up our VPS website is successful. If we like to use other backup methods, we can also use Dropbox’s automatic backup and our automatic backup to FTP space. Even if you are afraid of trouble, You can also perform regular manual backups.
Recommended site search: Hong Kong cloud host, domain name price, overseas server, proxy service IP, US host recommendation, domain name registration information query, view IP, to Period domain name query, website registration, foreign vps server rental,
发表评论