Tutorial on automatic and scheduled backup of MySQL Databases in Linux

Source: Internet
Author: User

Recently, I wrote a tutorial to implement automatic and timed backup for MySQL in Linux for later reference. I would like to share it with you. If you have any questions, please try again.

The premise is set to 00:00 in the morning, so that the stored data is from yesterday.

Speak nonsense. Start

1. First, I created/home/user/mysql_autobackup.sh

Note: The content of mysql_autobackup.sh is as follows:

/Usr/bin/mysqldump-uroot-ppassword_card>/st_backup/stcard _ $ (date + % Y % m % d). SQL

/Usr/bin/mysqldump-uroot-ppassword sthy_card>/st_backup/sthycard _ $ (date + % Y % m % d). SQL

2. Then add permissions for the script

# Chmod + x/Home/user/mysql_autobackup.sh

3. Then add crontab. The command is as follows:

# Crontab-e (similar to the vi Mode)

Then write the text:

0 0 ***/Home/user/mysql_autobackup.sh (that is, execute the script after 00:00 every day)

About0 0 *** if you don't understand this, you can find du Niang (Baidu). All kinds of explanations are available.

Save and exit (what? No? Esc, colon, X, and press Enter). The following message is displayed: crontab: installing new crontab.

Crontab added successfully

To verify the correctness, # crontab-l is displayed:

[Root @ localhost ~] # Crontab-l
0 0 ***/home/user/mysql_autobackup.sh

Yes .. ..

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.