Scheduled automatic VPS backup script to realize LLsMP environment website and database mailbox/FTP synchronization backup

888u

Last update at :2024-06-18,Edit by888u

Since we started using VPS, we need to pay special attention to data security. Whether we use the WEB panel, one-click installation package, or even directly compile the environment manually, we can choose to perform regular manual backups, or we can use the built-in WEB panel. Backup tools. Today, a user mentioned the issue of backing up the LLSMP environment, so in this article, Snail shared an automatic backup script that once existed in the blog, and then modified it to write a complete backup tutorial about the LLSMP one-click package environment.

Of course, if you use an LLSMP environment, you can also manually back up to the VPS space through the sh /root/llsmp/backup.sh command, and then download the backup via FTP. You can also upgrade this command to automatically execute and transfer data.

Snail has previously shared several articles about VPS backup:

Configure RSYNC to implement scheduled synchronization of mirror VPS website backup and replace incremental backup files

Linux VPS automatically synchronizes backup files/databases to the COPY storage site

Use the AMH panel to automatically back up VPS host data to your mailbox on a scheduled basis

Among the many tutorials, we only need to choose the one that suits our own habits. There is no need to use different methods for each environment and site. Let’s start today’s article by sharing about the automatic scheduled backup and the backup process submitted to the mailbox and FTP host.

First, install the sendmail component

Because in this script, I will use email and FTP to send together to ensure data security, so I use a multi-channel backup method. I use sendmail to send emails, so I need to install the component.

apt-getinstall sendmail mutt

Run the above script in debian. If it is centos, just replace apt-get with yum. Then enter y in the prompt and press Enter to install. It is best to restart the VPS to take effect.

Second, upload script editing parameters

https://soft.laozuo.org/scripts/autobackuptoftp.sh

Download the script locally and compile the corresponding information:

MYSQL_USER=Database user MYSQL_PASS=Database password MAIL_TO=Sending email FTP_USER=FTP username FTP_PASS=FTP password FTP_IP=FTP account IPFTP_backup=Backup FTP path folder WEB_DATA=/home/wwwroot #Local backup path

Then upload it to the ROOT directory.

Third, execute script scheduled backup

chmod +x /root/autobackuptoftp.sh #Execute the file to grant permissions crontab -e #Prepare to add timing settings 00 00 * * * /root/autobackuptoftp.sh #Insert the previous script after the i command and press Enter, which means Back up data at 12 midnight every day

Note: We can also execute sh/root/autobackuptoftp.sh first to see if the manual backup and synchronization can be successful.

After execution, I can see a database and a website file in the backup FTP space.

In this way, the method of automatically backing up websites and databases in the LLSMP script environment is completed. It is best to back up manually first. If the backup fails, you can see the reason and then solve the problem before automatically backing up. Otherwise, it will not work.

Recommended site search: website domain name registration, check IP detailed address, cloud host, cloud host, private server rental, la domain name, which Hong Kong server is the fastest, registration-free jsp space, Hong Kong cn2 server, domain name price,

Scheduled automatic VPS backup script to realize LLsMP environment website and database mailbox/FTP synchronization backup

All copyrights belong to 888u unless special state
取消
微信二维码
微信二维码
支付宝二维码