Pagoda automatic backup website to mailbox tutorial

Original link: https://zburu.com/2022/05/25/130.html

foreword

The advantage of frequent website backup is that it can be quickly restored after encountering a problem, which is not so passive, prevents information loss, and has great operability. Although it is very easy to build a website, in order to deal with various unexpected situations on the Internet and avoid your own website being in vain, it is very necessary to make a backup of your website.

Now mailbox receiving supports attachment files, and it is also a good backup method to backup website files and database files to our own mailbox, and also prevent the loss of backup files.

The size of the attachment file received by the mailbox depends on the mailbox service used. Generally speaking, personal blog website source files, database files are not large, and common mailbox services can be used.

Let’s start the tutorial. For the pagoda installation tutorial, you can go to the pagoda official website to view the installation tutorial.

System environment: CentOS 7.9.2009 x86_64 (other systems can refer to the method, and the command installation can be solved by itself)

Pagoda Panel: 7.9.0

install mailx

Browser login to enter the pagoda panel, left – ” terminal . When using the Pagoda terminal for the first time, you need to log in to the server, fill in the root user password and log in.

13-1.webp

Enter the following mailx installation command in the terminal and press Enter to install.

 yum install -y mailx

13-2.webp

Edit configuration file

After the installation is complete, edit the relevant configuration files of the mailbox service.
Enter the following command in the terminal, and then press Enter to enter the editing file interface.

 vim /etc/mail.rc

13-3.webp

Use the up and down keys on the keyboard, find the position about 69 lines, press the ‘i’ key to enter, add the following configuration.

 set from=发件人@qq.com #发送邮件后显示的邮件发送方需要修改set smtp=smtps://smtp.qq.com:465 #SMTP服务器的网址及端口需要修改set smtp-auth-user=发件人@qq.com #发送邮箱需要修改set smtp-auth-password=邮箱密码/SMTP授权码#设置的邮箱密码,SMTP授权密码需要修改set smtp-auth=login #动作、登录无需修改set ssl-verify=ignore #ssl验证忽略无需修改set nss-config-dir=/etc/pki/nssdb #证书存放目录无需修改

Please modify the configuration as required to the mailbox service configuration you use. The server needs to open port 465.

13-4.webp

13-5.webp

After the configuration modification is completed, press the Esc key, enter :wq and press Enter to save and exit the editing interface.

Test sending email

Enter the send test mail command in the terminal, you need to modify the recipient’s mailbox, and press Enter to execute.

 echo "这是一封测试邮件" | mail -s "邮件主题" 收件人@qq.com

13-6.webp

Check to see if the mailbox has received a test email.

13-7.webp

If you find that the terminal reports the following error (but it does not affect the receipt), please skip it if there is no error.

Error in certificate: Peer's certificate issuer has been marked as not trusted by the.

13-8.webp

After Ctrl+C ends the command, modify the mailbox service configuration file, change set ssl-verify=ignore to set ssl-verify=strict , save and exit (the editing method is the same as above).

13-9.webp

After the modification is complete, enter the following command in the terminal.

Get mail server certificate

 echo -n " " | openssl s_client -connect smtp.qq.com:465 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFIICATE-/p' > /etc/pki/nssdb/qq.crt

Add the certificate to the trusted list

 certutil -A -n 'yeah' -t "P,P,P" -d /etc/pki/nssdb -i /etc/pki/nssdb/qq.crt

Note: If it is 163 or other mailbox servers, please change smtp.qq.com to smtp.163.com , qq.crt to 163.crt and so on.

After the command is executed, re-execute the send test email command, and no error is reported.

13-10.webp

Pagoda timed task

Left – ” Scheduled Tasks

First, add website and database source file backup tasks according to your own needs (planned task execution time, number of retained files, etc.).

13-11.webp

Then add a shell script task, add the following script command to the script content, and modify the recipient to be your own mailbox.

 #!/bin/bash cd /www/backup/site for file in $(ls *) do str="${str} -a ${file}" done echo "主人,今天的网站备份又到了哦,请注意查收!" | mail -s "网站备份" $str [email protected]

13-12.webp

The execution time can be as required, later than the website, database backup task execution time.

Database backup and website backup need to add another scheduled task. cd /www/backup/site to cd /www/backup/database The directory where the database backup file is located can be changed. For reference, change the subject of the email and the content information.

After the scheduled task is added, you can perform the website and database source file backup task first, then execute the website and database mailbox shell script backup task, and then go to the mailbox to check whether the file is received. If the file is too large, the mail will be delayed.

13-13.webp

13-14.webp

Note: If an error is reported or the email cannot be received, please carefully check the command and configuration file for errors, or check the script execution log for troubleshooting.

Reprinted from Meng Fanxing’s blog: https://blog.emoao.com/13.html

If you have any questions, please leave a message in the comment area.

This article is reproduced from: https://zburu.com/2022/05/25/130.html
This site is for inclusion only, and the copyright belongs to the original author.

Leave a Comment

Your email address will not be published.