VPS back up website files and shell script tools from databases to cloud storage
The tool shared today is also related to backup and remote backup. This tool is boring, although WordPress already has a backup plug-in such as wp2pcs. I believe that the webmaster of VPS will like this tool because it will not occupy resources.
I. Tool Archives
Tool Name: Backup_to_qiniu_by_zhangge-Ver1.0.sh
Tool language: Shell, json
Working environment: Linux
Function Description: schedules tasks in Linux to back up website files and databases to qiniu free cloud storage space.
Additional instructions:
The ghost tool uses zipping. if the system does not have zipping installed, it uses the Tartar package into the tar.gz format;
② In order to avoid Chinese garbled characters, all tools use foreign languages. The level of Zhang Ge is limited, and there may be a Chinese comparison below in the lame syntax );
③ Use the native interaction style. If the interface menu is not optimized, it will be used once for initialization.
Ii. Instructions for use
① Download tool:
Go to the VPS system and run the following command to download the tool:
- cd && wget http://mymsdn.qiniudn.com/backup/Backup_to_qiniu_by_zhangge-Ver1.0.sh
② Run the tool and enter the information as prompted:
- cd && ./Backup_to_qiniu_by_zhangge-Ver1.0.sh
The process is as follows:
- [Root @ jiukeyi ~] #./Backup_to_qiniu_by_zhangge-Ver1.0.sh
- Please input the webroot like/domain/zhangge.net/public_html:enter the path of your website file
- Please input the access_key: Enter the access_key of qiniu.
- Please input the secret_key: Enter secret_key of qiniu
- Please input the bucket name: enter the name of the Seven cattle Space
- Please input the mysql username: Enter the database account
- Please input the mysql password: Enter the Database password
- Please input the database name: Enter the database name
- Please input the backup path: Enter the temporary storage path of the backup file. Press enter to store the file in/usr/local/qiniu/backup.
- Please input the backup rate time (like 1/2/3 .. 30): Enter the backup interval. For example, input 7 indicates that backup is performed every seven days.
- # When you press enter, the message is successful:
- ==================================== The crontab list ============== ==================================
- # Add by QN_Backup Scripts
- 0 0 */7 ** sh/usr/local/qiniu/QN_backup.sh/www/web/default test2 123456/www/backup_temp mytest
- ==================================== The crontab list ============== ==================================
- Compelet!
The following is a test:
After the command is executed, you can copy the command line of crontab and manually execute the following command:
- sh /usr/local/qiniu/QN_backup.sh /www/web/default test2 123456 /www/backup_temp mytest
After the backup is successful, the space corresponding to qiniu will be able to see the file you just backed up:
The above process is initialization and only needs to be executed once. Of course, repeated execution does not matter, but only overwrites the settings.
Iii. Post-Maintenance
After completing the initialization settings, if you want to change the backup interval or backup target, you can edit the system scheduled task to redefine it:
- # Run crontab-e to open the scheduler task editing page.
- [Root @ jiukeyi ~] # Crontab-e
- # Add by QN_Backup Scripts
- 0 0 */7 ** sh/usr/local/qiniu/QN_backup.sh/www/web/default test2 123456/www/backup_temp mytest
The above 4th lines are Backup command lines, and the following are post-modification instructions:
The first five columns indicate the execution frequency, specifically the hour, day, month, and week. The tool is defined by day by default. */7 in the Code indicates that the backup is performed every 7 days;
/Www/web/default: Path of the website file to be backed up
Test2, 123456: database user name and password
/Www/backup_temp: backup file storage address. Each backup file is retained until the next backup is deleted. This is almost a local backup.
Mytest: Database Name
Ps: Of course, you can also insert Multiple Task plans based on your actual needs.
Iv. Outlook on tools
This tool is just a boring work of Zhang GE. There are not many VPS users, and they all have their own backup systems. The purpose of this tool is only to provide a way out for the backup website.
Depending on the popularity, the next version of the tool will be added
① Custom mechanism for separate backup of website files/databases;
② Make menus and separate projects, including interactive menus maintained at a later stage to improve ease of use
Source: Zhang Ge blog Author: Zhang Ge original link: http://zhangge.net/4212.html