I wrote two blog posts on VPS security settings in a few days. In fact, no matter how secure we are, backing up VPS data in a timely manner is the most important thing. Because the VPS is different from the host, the host may often be backed up by the service provider on our behalf. Most of the operations and security of VPS require us to be responsible for this. Even if many VPS provide daily backup services, but there are too many uncertain factors. For example, the merchant runs the road, the hard disk of the master machine is damaged, and uncontrollable factors.
There are also many methods available for VPS backup tutorial methods. For example, we can download conventional backup files directly through FTP, and export MYSQL Databases can also be operated, but these operations are troublesome, in addition, manual execution is required. In this article, I would like to share with you the commonly used automatic and scheduled backup solution. The database is sent to our mailbox and the file is sent and synchronized to another FTP space. Before writing this article, I also refer to other people's methods on the Internet. I have to test it myself before I can be sure of the Feasibility. So I will sort out this article, A friend in need can test with the old left.
First, my backup environment is centos. First install the sentmail component:
The Code is as follows: yum install sendmail mutt
After executing this file, you should have gone through a series of tutorials. You don't need me anymore.
Next, download the automatic backup file to the local device:
Open it with editplus or notepad and modify it to your own content. There are remarks in the future, which should be relatively simple. After modification, we need to create a backup folder under the wwwroot VPS space that we need to back up, and all the folders that you do not have in the remote FTP space need to be created manually, it is difficult to back up the directory that cannot be found during the backup operation.
Upload autobackuptoftp. sh to the ROOT directory of our VPS:
The Code is as follows: chmod + x/root/autobackuptoftp. sh # grant permissions to the execution File
Crontab-e # Prepare to add timing settings
00 00 ***/root/autobackuptoftp. sh # Run the I command and press enter to insert the preceding script, which means to back up data at midnight every day.
Finally, we can test the file sh autobackuptoftp. sh to perform backup.
Note: The above automatic backup tutorial will also send a database backup to our mailbox for security reasons, because the database is more important than the file; and files and databases will be synchronously sent to the BACKUP folder of the backup ftp and website space. The third-party BACKUP ensures data security.