Linux VPS Auto-timed backup website files and MySQL database to FTP space (LNMP)

Source: Internet
Author: User
Tags best vps vps

If our site update is not very frequent, we can regularly manually make backup site files and MySQL database export. If our site data update frequently, and the data is particularly important, it is recommended to use regular automatic backup, at least the need to backup data, no matter what we choose the best VPs, server, we have to beware of server or accidental problems caused data loss.

In this article, the Bricklayer Chinese network is ready to have a set of LNMP one-click Environment use regular backup database and Web site file packaging, directly upload to the alternate FTP space. For example, you can find some virtual host space, hard disk storage is also relatively large, directly can be used as backup data.

First, pre-backup preparation

1. Prepare an FTP host space

2. When we first use this script, we need to back up the data to prevent

3, at present I am in LNMP a key package environment test.

4. Install SendMail components (yum install SendMail mutt)

Second, download the script

http://www.cnbanwagong.com/tools/backup-ftp.sh

Third, modify the configuration file

#!/bin/bash
#你要修改的地方从这里开始
Mysql_user=root #mysql用户名
mysql_pass=123456 #mysql密码
[Email protected] #数据库发送到的邮箱
Ftp_user=cat #ftp用户名
ftp_pass=123456 #ftp密码
Ftp_ip=123.123.123.123 #ftp地址
Ftp_backup=backup #ftp上存放备份文件的目录, this is going to have to be built on your own FTP.
Web_data=/home/www/cnbanwagong.com #要备份的网站数据
#你要修改的地方从这里结束

Modified according to our actual information. Then replace it with the server.

IV, set permissions, set up regular execution

1. Set permissions

chmod +x/root/backup-ftp.sh

2, set the timing

Crontab-e

Then add the Execute script

* * * * */root/backup-ftp.sh

Set to execute 1 o'clock in the morning every day.

3. Whether the test is effective

sh/root/backup-ftp.sh

Here we can perform a look, if the normal backup to the FTP space, the description is no problem, if there is a problem, we can recheck.

Linux VPS Auto-timed backup website files and MySQL database to FTP space (LNMP)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.