In view of the uncertainty of domestic servers, data is often lost recently, so a one click backup and recovery script for this pagoda panel site and database is specially issued. There are two files, backup script (backup. sh) and restore script (restore. sh).
The script's related functions and features are as follows:
1. Support multiple backup storage locations, including remote server (scp), AliCloud OSS, Tencent Cloud COS, Huawei Cloud OBS, Baidu Cloud BOS
2. Not only can all website files and databases be backed up, but also various website settings such as binding domain names, pseudo static, reverse proxy, notes, SSL certificates of all websites can be backed up. The pagoda's built-in backup function only supports the backup of website files and databases, and does not support the backup of website settings.
3. XtraBackup is used for database backup to realize physical hot backup. Even large amounts of data can be quickly backed up and restored, and the backup and restore process takes up less system resources. The built-in database backup of the pagoda is a logical backup, which is slow and consumes a lot of CPU.
4. After the backup script is set, add it to crontab to realize automatic scheduled backup.
5. Newly install the pagoda panel, download the backup file, and immediately restore the website business access after executing the one click recovery script, without additional operations such as manually creating the website.
Backup script (backup.sh ） usage method:
1. First install XtraBackup for database physical hot backup (take CentOS 7 as an example)
wget http://file.kangle.cccyun.cn/file/percona-xtrabackup-24-2.4.24-1.el7.x86_64.rpm yum -y install percona-xtrabackup-24-2.4.24-1.el7.x86_ 64.rpm
2. Open the backup script with an editor（ Never edit with Windows Notepad! ）, modify the database password, backup storage location type and other related information. Then upload to the server.
#Give the backup script execution permission chmod 755 /root/backup.sh #Add to crontab, set daily backup at 2:00 crontab -e 0 2 * * * /root/backup.sh >/root/backup.log 2>&1
3. Configuration related to backup storage type
If you choose to back up to cloud storage, it is recommended that cloud storage and cloud server are not under the same account. Otherwise, if the account is blocked, it is equivalent to no backup.
(1) The backup storage location type is remote linux server Description:
You need to configure password free login, and execute the following commands on the two servers respectively
ssh-keygen -t rsa -P '' -f ~/.ssh/id_ rsa
Execute the following command on the server that needs to back up data
ssh-copy-id -i ~/.ssh/id_ Rsa. pub root @ remote server IP
Then enter the password of the remote server according to the prompt to complete the configuration of password free login.
(2) The backup storage location type is AliCloud OSS Description:
Execute the following command to complete the installation and configuration of ossutil（ Reference Address ）
wget -O ossutil http://gosspublic.alicdn.com/ossutil/1.7.9/ossutil64 mv ossutil /usr/bin chmod +x /usr/bin/ossutil Ossutil config - e<OSS Endpoint>- i<your ak>- k<your sk>
(3) The backup storage location type is Tencent Cloud COS Description:
Execute the following command to complete the installation and configuration of coscli（ Reference Address ）
wget -O coscli https://download.fastgit.org/tencentyun/coscli/releases/download/v0.10.2-beta/coscli-linux mv coscli /usr/bin chmod +x /usr/bin/coscli coscli config #Enter the Secret ID, Secret Key, Bucket Name and Bucket Region parameters according to the prompt. The Session Token and Bucket Alias can be left blank and entered directly
(4) The backup storage location type is Huawei Cloud OBS Description:
Execute the following command to complete the installation and configuration of obsutil（ Reference Address ）
wget https://obs-community.obs.cn-north-1.myhuaweicloud.com/obsutil/current/obsutil_linux_amd64.tar.gz tar -xzvf obsutil_ linux_ amd64.tar.gz cd obsutil_ linux_ amd64* mv obsutil /usr/bin chmod 755 /usr/bin/obsutil cd .. rm -rf obsutil_ linux_ amd64* obsutil config -i=<ak> -k=<sk> -e=<endpoint>
(5) The backup storage location type is Baidu Cloud BOS Description:
Execute the following command to complete the installation and configuration of boscmd（ Reference Address ）
wget https://bce-doc-on.bj.bcebos.com/bce-documentation/BOS/linux-bcecmd-0.3.2.zip unzip linux-bcecmd-0.3.2.zip mv linux-bcecmd-0.3.2/bcecmd /usr/bin chmod 755 /usr/bin/bcecmd rm -f linux-bcecmd-0.3.2.zip bcecmd
(6) The backup storage location type is Qiniu Cloud Description:
Execute the following command to complete the qshell installation and configuration（ Reference Address ）
wget https://devtools.qiniu.com/qshell-v2.6.2-linux-amd64.tar.gz tar zxvf qshell-v2.6.2-linux-amd64.tar.gz mv qshell /usr/bin chmod +x /usr/bin/qshell rm -f qshell-v2.6.2-linux-amd64.tar.gz qshell account <ak> <sk> <name>
Recovery script（ restore.sh ）Usage:
Note: Before restoring, you must install the pagoda panel and ensure that no website or database has been created! If it has been created, delete it before executing the recovery script!
Open the backup script with an editor（ Never edit with Windows Notepad! ）, modify the database password, and then upload it to the directory where the backup file is located (the directory must contain wwwroot. tgz, mysql. tgz, config. tgz)
#Give permission to execute the recovery script chmod 755 ./ restore.sh #Perform recovery ./restore.sh
1：bt_ Backup.zip (Tiger Green Forest Qiniu Cloud Storage Download)
The content is reprinted from the Internet, invaded and deleted
Tiger Green Forest@ net909 @Colorful Rainbow World