Example of setting up Mysql automatic backup under Ubuntu _mysql

Source: Internet
Author: User
Tags mysql automatic backup mysql backup
1. Create a path to save the MySQL backup file/mysqldata
#mkdir/mysqldata

2. Create/usr/sbin/bakmysql files
#nano/usr/sbin/bakmysql

Input:
Copy Code code as follows:

#!/bin/sh
Name= ' date+%y%m%d '
mysqldump--all-databases-uroot-p Password >/var/mysqlbak/mysql.sql


Note:--all-databases to back up all the databases to the Mysql.sql file under Mysqlbak, if you replace--all-databases with test, only the test database is backed up.

3, modify the file properties to make it executable
# chmod +x/usr/sbin/bakmysql

4. Modify/etc/crontab
#nano/etc/crontab

Add the following:
3 * * * root/usr/sbin/bakmysql
Indicates that a backup is scheduled to be performed 3 o'clock every day.

5, restart Crond
#/etc/init.d/cron Restar

Complete.
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.