Routine database backup in Linux

Source: Internet
Author: User
#! /Bin/bash # Name of the database to be backed up DB_NAME = & quot; xxx & quot; # Name of the database to be backed up DB regularly backs up the database on a daily basis in Linux

1. on the home page, we need to write a script named bakdata. sh. the storage path is/root/bakdata. sh. The content is as follows:

PHP #! /Bin/bash # Name of the database to be backed up DB_NAME = "xxx" # Name of the database to be backed up DB_USER = "xxx" # password of the database to be backed up DB_PASS = "xxx" # MySQL installation Path (based on actual conditions) BIN_DIR = "/usr/local/mysql/bin" # directory of the file to be backed up BACK_DIR = "/var/mysql_bak" # backup format (daily storage) DATE = "'date + % Y % m % d'" $ BIN_DIR/mysqldump -- opt-u $ DB_USER-p $ DB_PASS $ DB_NAME> $ BACK_DIR/$ date. SQL
1234567891011121314 #! /Bin/bash # Name of the database to be backed up DB_NAME = "xxx" # Name of the database to be backed up DB_USER = "xxx" # password of the database to be backed up DB_PASS = "xxx" # MySQL installation Path (based on actual conditions) BIN_DIR = "/usr/local/mysql/bin" # directory of the file to be backed up BACK_DIR = "/var/mysql_bak" # backup format (daily storage) DATE = "'date + % Y % m % d'" $ BIN_DIR/mysqldump -- opt-u $ DB_USER-p $ DB_PASS $ DB_NAME> $ BACK_DIR/$ date. SQL

2. use the crontab command in Linux to regularly execute scripts.

Crontab-e
1 Crontab-e

3. write the following content and save and exit (data is backed up at every day ).

PHP # bakdata 15 00 ***/bin/bash/root/bakdata. sh
12 # Bakdata15 00 ***/bin/bash/root/bakdata. sh
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.