Prepare to have a built LNMP key environment packaged with regular backup database and website files and uploaded directly to the spare FTP space. For example, you can find some virtual host space, hard disk storage is relatively large, can be used as standby data directly.
First, preparation before backup
1. Prepare an FTP host space
2. When using this script for the first time, we need to backup the data in case of emergency.
3. At present, I am testing in LNMP keypack environment.
4. Install sendmail component (yum install sendmail mutt)
Second, download scripts
Third, modifying configuration files
#!/bin/bash # Here's where you need to modify it. MYSQL_USER=root#mysql username MYSQL_PASS=123456#mysql password MAIL_TO=mailbox sent by [email protected] database FTP_USER=cat#ftp username FTP_PASS=123456 FTP password FTP_IP=220.127.116.11#ftp address FTP_backup = backup ftp, the directory where backup files are stored, which you have to build on ftp. WEB_DATA=/home/www/cnbanwagong.com# Web site data to be backed up # Where you want to change ends here.
Modify according to our actual information. Then replace it to the server.
Fourth, set up authority and set periodic execution
1. Setting permissions
chmod +x /root/backup-ftp.sh
2. Setting Timing
Then add the execution script
00 01 * * * /root/backup-ftp.sh
Set to be executed at 1 a.m. every day.
3. Is the test valid?
Here we can perform a look, if the normal backup to FTP space, that is no problem, if there is a problem, we can re-check.