MYSQL database automatic local/remote Dual Backup/MYSQL Incremental Backup [Build millions of visits to e-commerce websites]

Source: Internet
Author: User
Tags mysql backup
MYSQL database automatic local remote dual-Backup MYSQL Incremental Backup [Build millions of access to e-commerce websites] Source: jimmyli.blog.51cto.com I stood on the shoulders of giants JimmyLi Author: JimmyLi

MYSQL database automatic local/remote dual-backup/MYSQL Incremental Backup [Build millions of visits to e-commerce websites] Source: http://jimmyli.blog.51cto.com/ I am standing on the shoulders of jimmyli :jimmyli

MYSQL database automatic local/remote Dual Backup/MYSQL Incremental Backup [Build millions of visits to e-commerce websites]

Source: I stand on the shoulders of giants, Jimmy Li
By Jimmy Li
Keywords: website, e-commerce, Shell, automatic backup, remote backup
------ [Connected E-commerce system architecture] technical architecture of e-commerce websites with more than 1 million visits
Connection: Technical Architecture of e-commerce websites with more than 1 million visits
Architecture diagram of building a high-security e-commerce website (automatic local/remote Dual Backup of website files and databases)

We will continue to introduce the E-commerce system architecture related to file backup, database backup, and data security storage on Linux servers. There are a variety of security solutions, data backup is the top priority.
E-commerce websites pay more attention to data security and data backup solutions, including local backup and remote backup architectures. There are many backup solutions for Linux servers. This article introduces a popular and suitable solution to complete automatic backup by writing Shell scripts. This architecture includes backing up website files and databases, automatically backing up local data, uploading backup scripts over FTP, and completing local backup and remote backup to implement a dual-layer backup solution.

Key points of this article:

1. MYSQL database automatic local/remote Dual Backup/MYSQL database Incremental backup.
2. Write a Shell script to complete automatic MYSQL backup and MYSQL database Incremental backup.
3. both local and remote backup and FTP backup are performed simultaneously.
4. backup solution for Linux servers.
5. Shell scripts include backing up website files, website program files, data files, and MYSQL databases.
6. Regular and scheduled backups are automatically completed. Regular deletion of old backup. Here, the backup is automatically deleted 30 days ago, and the backup space is reused.

Directory:

I. Preparations
Ii. Website O & M remote backup solution and fault emergency backup mirror station architecture
Iii. script for automatic local/remote dual-backup of MYSQL database/Shell for Incremental backup of MYSQL database, complete instance; detailed explanation and comment on the backup script.


At the beginning of the e-commerce website in operation, we have been reiterated that we must back up our own data, because too much uncertainty may cause database loss, in addition, most basic service providers cannot provide daily backup data. The original BLOG provided a backup method, server space, introduced the Shell script MYSQL database automatic backup, did not introduce MYSQL database Incremental backup. Today I will share my own backup script.
Refer to the previous article "Building a high-security e-commerce website (automatic local/remote dual-backup of website files and databases) [serialization of E-commerce system architecture]"

I. preparations:

After lftp is installed on the Linux server, you must create the/home/backup directory on the Linux server in advance. And ensure that FTP can normally use the account password to log on to the last file. It ensures that the FTP service provides services normally.


Ii. Website O & M remote backup solution and fault emergency backup mirror station architecture


Iii. Website MYSQL database automatic local/remote Dual Backup/MYSQL database Incremental Backup Shell script

Script 2:
MYSQL database Incremental Backup Shell script

If the database data volume is large, you can perform full backup once a day, and then perform Incremental backup once every one hour;
Create an Incremental Backup Directory
The Incremental backup files are stored in the/backup/mysql/daily directory.
The Incremental backup data volume is small, but must be performed on the basis of the complete backup.

The Incremental Backup uses the bin log. The script is as follows:

Shell


Script parsing description:
The Incremental backup script is flush-logs before the backup. mysql will automatically put the logs in the memory into the file and generate a new log file. Therefore, we only need to back up the first few logs, that is, do not back up the last one.
Because multiple log files may be generated from the last backup to the current backup, you do not need to back up the files if the files have been backed up.

Tip: Incremental Backup:
Perform full backup at PM and PM every day, and back up binlog every one hour, that is, Incremental backup. The specific operations are as follows:

Enable binlog in Linux

Put the script under/root/and the Hong Kong VM. Modify the parameters in the script according to the preceding annotations, use the vim editor, and save the script.
Run: chmod + x/root/backup. sh to add the execution permission for the script.
Run: crontab-e.
Add: 0 3 ***/root/backup. sh to crontab.
The/root/bakcup. sh script is automatically executed at a.m. to back up data on the Linux server and upload it to the preset remote FTP.
Back up your website at because the website traffic during this period is the lowest. That is to say, backup is performed when few people access it.

Source: Jimmy Li Blog. You are welcome to discuss and communicate with each other. Deduction: ⑥ ()


MYsql Binlog



Script 1:
The website and database are automatically backed up locally and FTP is used to upload the backup Shell script, a Hong Kong server, and a complete instance:

========================================================== ======================================

Shell


For a detailed explanation of the backup script, see building a high-security e-commerce website (automatic local/remote dual-backup of website files and databases) [connected E-commerce system architecture].
========================================================== ======================================

Website O & M remote backup solution and fault emergency backup mirror Station

Enable emergency Web service when remote backup fault emergency is regularly checked
Connection: website O & M remote backup solution and fault emergency backup mirror Station

This article is from the "Jimmy Li I am standing on the shoulders of giants" blog. Please keep this source

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.