The original VPS detective provided a VPS backup method, just a little said, maybe some newcomers will not start well. Today VPS Detective shares a backup script of its own.
Preparation:
You need to install lftp in VPS in advance, lftp function is more powerful, CentOS directly executes: yum install lftp, Debian execution: apt-get install lftp.
You need to create the /home/backup/directory on the VPS and create a backup directory on the FTP.
If there are not many databases on the VPS, use Godaddy's free space (10GB space, 300GB traffic), as long as you register a domain name for free.
The following is a partial comment on the backup script:
#!/bin/bash
#Funciont: Backup website and mysql database
#Author: licess
#Website: http://lnmp.org
#IMPORTANT!!!Please Setting the Following Values!
#######~Set Directory you want to backup~###### The directory is changed to the directory that you want to back up. Generally, all of them are written under /home/wwwroot/directly to the directory that needs to be backed up. You can continue to add: Backup_Dir5=Your directory, the number after Backup_Dir is incremented. If there are less than 4, you can delete the unnecessary ones directly, and modify the tar zcf part below.
Backup_Dir1=vpser.net
Backup_Dir2=lnmp.org
Backup_Dir3=licess.org
Backup_Dir4=jungehost.com
######~Set MySQL UserName and password~######Set the MySQL username and password, preferably root. Other users may not be able to export some databases due to permissions issues.
MYSQL_UserName=root
MYSQL_PassWord=yourmysqlrootpassword
######~Set MySQL Database you want to backup~######Set the database to be part of, you can continue to add: Backup_Database_Name5=Database name, the number following Backup_Database_Name is incremented.
Backup_Database_Name1=vpser
Backup_Database_Name2=licess
Backup_Database_Name3=junge
Backup_Database_Name4=vpserorg
######~Set FTP Information~######Settings are used to FTP information for storing backup data
FTP_HostName=184.168.192.43 //FTP server IP or domain name
FTP_UserName=vpsernet //FTP server username
FTP_PassWord=yourftppassword //FTP server user password
FTP_BackupDir=backup //Back up to the directory on FTP and need to create it in advance.
#Values Setting END!
TodayWWWBackup=www-*-$(date +"%Y%m%d").tar.gz
TodayDBBackup=db-*-$ (date +"%Y%m%d").sql
OldWWWBackup=www-*-$(date -d -3day +"%Y%m%d").tar.gz
OldDBBackup=db -*-$(date -d -3day +"%Y%m%d").sql
tar zcf /home/backup/www-$Backup_Dir1-$(date +"%Y%m% d").tar.gz -C /home/wwwroot/$Backup_Dir1 --exclude=soft
tar zcf /home/backup/www-$Backup_Dir2-$(date +"%Y%m%d"). Tar.gz -C /home/wwwroot/$Backup_Dir2
tar zcf /home/backup/www-$Backup_Dir3-$(date +"%Y%m%d").tar.gz -C /home/wwwroot /$Backup_Dir3 --exclude=test
tar zcf /home/backup/www-$Backup_Dir4-$(date +"%Y%m%d").tar.gz -C /home/wwwroot/$Backup_Dir4< Br>
###The above is the backup website file data, because my website is scattered, and some directories under the website directory belong to the temporary directory and do not need to be backed up, so you can add --exclude= not backed up the directory . If Backup_Dir5=yourdir is added in front, add tar zcf /home/backup/www-$Backup_Dir5-$(date +"%Y%m%d").tar.gz -C
/home/wwwroot /$Backup_Dir5 . If it is redundant, delete the extra line.
/usr/local/mysql/bin/mysqldump -u$MYSQL_UserName -p$MYSQL_PassWord $Backup_Database_Name1 > /home/backup/db-$Backup_Database_Name1-$(date +"%Y%m%d" ).sql
/usr/local/mysql/bin/mysqldump -u$MYSQL_UserName -p$MYSQL_PassWord $Backup_Database_Name2 > /home/backup/db-$Backup_Database_Name2-$(date +"%Y%m%d" ).sql
/usr/local/mysql/bin/mysqldump -u$MYSQL_UserName -p$MYSQL_PassWord $Backup_Database_Name3 > /home/backup/db-$Backup_Database_Name3-$(date +"%Y%m%d" ).sql
/usr/local/mysql/bin/mysqldump -u$MYSQL_UserName -p$MYSQL_PassWord $Backup_Database_Name4 > /home/backup/db-$Backup_Database_Name4-$(date +"%Y%m%d" ).sql
###The above is the backup MySQL database, if you add Backup_Database_Name5=yourdatabasename in front, then add /usr/local/mysql/bin/mysqldump -u$MYSQL_UserName -p$MYSQL_PassWord $Backup_Database_Name5 > /home/backup/db-$Backup_Database_Name5-$(date +"%Y%m%d").sql . If it is redundant, delete the extra line.
rm $OldWWWBackup
rm $OldDBBackup
###Remove backups 3 days ago###
cd /home/backup/
## #以下为Automatic upload part, I have to say that lftp is very powerful, abandon ftp####
lftp $FTP_HostName -u $FTP_UserName, $FTP_PassWord << EOF
cd $FTP_BackupDir
mrm $ OldWWWBackup
mrm $OldDBBackup
mput $TodayWWWBackup
mput $TodayDBBackup
bye
EOF
Script download address: http://soft.vpser .net/lnmp/backup.sh
Download the script, put the script under /root/, modify the parameters in the script according to the above comments, and save it. If you are not familiar with vi or nano editor, you can use Winscp, execute: crontab -e
Add in crontab: 0 3 * * * /root/backup.sh
Automatically execute /root/bakcup.sh script at 3 am, backup vps The data on it is uploaded to FTP.
. This is to help some rookie webmasters solve the problem that IIS does not have a net2.0 option ca
After setting up a web server, the most concerned about the use of th
Let your website open second, enable for IIS "content expiration&&&;quo; Wha
What is a cluster? A cluster is a group of independent computer systems that fo
Solution for the Apache2 service to stop due to a 1 (0x1) service error
Talking about the threats encountered by the paid website
Server update is not the best solution
Actual combat: Windows sever 2008 FAQ
How much do you know about Windows Server Hardening?
How to deal with data center cloud storage disaster recovery?
Explain Linux server hacking solution
Planning server virtualization should consider the top ten issues
The basics of the mail server are explained in detail
Network administrators maintain anti-black skills in the server process
Win7 reduces the shutdown waiting time skill
100 series motherboard installation Win7 mouse failure solution
Win8 mouse property change method
How to set the shared password
Microsoft released multiple B2B
Forcibly crack the encrypted WinRAR file
A simple and practical tutorial to improve the speed of Firefox
Win10 first anniversary update part of UWP application flashback crash how to do
Two strokes will get the automatic login of Windows 7 system.
What should I do if the NumLock key of the Win7 keypad is invalid?