Regardless of our VPS, the server uses which kind of web environment, since chooses to use will need to consider the transportation peacekeeping management, not only the website itself, its website data, the server security and so on aspect all needs to consider, especially the website file and the database all needs the regular backup to ensure the data integrity. In general, we will use the network more commonly used web panels, the environment a key package installation lamp, LNMP and other sites to set up the environment, and these commonly used in the mature environment will be a more automated application module.
For example, when we need to back up the site, you can use a regular manual backup database and Web site files (refer to here), you can also use the script's own modules for backup, such as the recent period of more popular Oneinstack one-click Package Environment (one-click Package installation) also has the ability to quickly back up the site data, It can also be scheduled for local and remote server backups. In this article, Chiang demonstrated how to use the Oneinstack one-key package to take a backup script locally, remotely, and regularly back up Web site files/databases in a test machine environment.
First, oneinstack Backup preparation work
The method shared by Chiang in this article is based on the Oneinstack scripting environment, so if other web environments are not available, we can use the corresponding method or manual backup for other environments, and if we need to synchronize remote backups to other VPs, servers, Need to prepare a server and root account information, etc. will need to use.
Second, Oneinstack take advantage of the script backup process
The code is as follows |
Copy Code |
./backup_setup.sh
|
According to the above illustration, we select the parameters that need to be backed up, such as a local backup, a remote backup, or a local and remote simultaneous backup. The system then detects our current database name and backs up the required databases as needed.
According to the prompts we also need to enter the site that needs to be backed up, according to the system detection and then enter the corresponding domain name, such as my side need to back up m.111cn.net, www.111cn.net, in the middle of a comma separated by English. If the input error cannot continue, then the parameters are set according to the IP address and account of the remote server.
The code is as follows |
Copy Code |
./backup.sh
|
After setting the parameters, perform a command backup. Of course, we can also regularly add automatic backups.
The code is as follows |
Copy Code |
Crontab-e
|
Then add the script to the timed file to perform the timed execution.
The code is as follows |
Copy Code |
0 1 * * * CD ~/oneinstack;. /backup.sh >/dev/null 2>&1 &
|
Third, Oneinstack script environment Backup summary
Through the above demo, we can complete the use of scripts from the backup command local, remote and can regularly back up the database and Web site files. In general, our personal small Web site also does not have the necessary scheduled backup, we can manually back up to the local and then download, after all, synchronization to other servers can lead to the risk of unsafe data leakage.