MySQL regularly backs up databases in Linux

Source: Internet
Author: User

How do I regularly back up MySQL Data? I have provided several methods for you to see. Supports regular and automatic backup of mysql Data in linux.

MySQL: shell script for automatic database backup in Linux
The programs on Linux Server Update the MySQL database every day, so they think of writing a shell script, combined with crontab, to regularly back up the database. In fact, it is very simple, mainly using the MySQL mysqldump command.

The script content is as follows:
#! /Bin/sh
# File:/home/mysql/backup. sh
# Database info
DB_NAME = "test"
DB_USER = "username"
DB_PASS = "password"

# Others vars
BIN_DIR = "/usr/local/mysql/bin"
BCK_DIR = "/home/mysql/backup"
DATE = 'date + % F'

# TODO
$ BIN_DIR/mysqldump-opt-u $ DB_USER-p $ DB_PASS $ DB_NAME | gzip> $ BCK_DIR/db_1_date.gz

Then add the script to the/etc/crontab scheduled task:

01 5 ** 0 mysql/home/mysql/backup. sh

All right, the system will automatically run the backup. sh file to back up the MySQL database at every Sunday.

/Home/www/inc/back

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.