First, install LFTP environment
Because we need to use the LFTP environment when uploading FTP files, we can't make sure all the systems are installed, so we'd better reinstall them first.
The code is as follows |
Copy Code |
#CentOS Yum Install lftp
#Debian Apt-get Install Lftp
|
Second, create a backup directory
The code is as follows |
Copy Code |
/home/backup/
|
We need to create a backup directory in the VPS, because in the execution of the backup, it is necessary to back up to the VPS local, and then upload from the local to the remote FTP space. We need to match this address with the following script.
Third, prepare the automatic backup script
The code is as follows |
Copy Code |
http://soft.itbulu.com/tools/backup.sh
|
We can download the above script to the local/vps and then modify the configuration. The main setting parameters are explained below by Chiang Kai-shek.
The code is as follows |
Copy Code |
######~ set up a Site Directory folder to be backed up ~######
Backup_dir1=itbulu.com
Backup_dir2=laojiang.me
Backup_dir3=shimaisui.com
Backup_dir4=website4.com
######~ Set up Database links ~######
Mysql_username=root
Mysql_password=yourrootpassword
######~ set the database name to be backed up ~######
Backup_database_name1=itbulu
Backup_database_name2=laojiang
Backup_database_name3=shimaisui
Backup_database_name4=website4
######~ uploaded FTP space information ~######
ftp_hostname=198.38.34.12
Ftp_username=itbulucom
Ftp_password=yourftppassword
Ftp_backupdir=backup//Backup to FTP directory, this need to build a directory ahead of time
#Values Setting end!
|
All we have to do is modify the backup.sh file above to make the site and database link information that we need to back up.
Upload the script to the root directory.
Set script permissions and scheduled backups
We upload to the VPS host root directory, and then set permissions
The code is as follows |
Copy Code |
chmod +x/root/backup.sh
|
The code is as follows |
Copy Code |
0 3 * * */root/backup.sh
|
Add the timed script above to perform a backup every 3 o'clock in the morning. We can first execute the script to see if it will work properly, if it can be set regularly. If our site data is not large, update frequency is not too much, we manually backup can also, there is no need to back up every day.