MySQL Automatic backup

Source: Internet
Author: User

The first MySQL automatic backup script.


#!/bin/bash

#auto backup MySQL database for test

#by Hag



Backcmd=/usr/bin/mysqldump

Dbuser=root

Dbpasswd=admin123

Databasename=test

Backup_dir=/opt/backup/mysql


if [!-D $backup _dir]; Then

Mkdir-p $backup _dir

Fi


If [$UID-ne 0]; Then

echo "must be root can run the script!"

Fi


$backCMD-u$dbuser-p$dbpasswd $databasename > $backup _dir/nimeide.sql


If [$?-eq 0]; Then

echo "This backup MySQL successfully!"

Else

echo "This backup MySQL failed!"

Fi

~

After writing the script, give execute permission.

[Email protected] script]# chmod 755 backmysql.sh

SH +x Debug Script sh +n detect if there is an error in the script!

[Email protected] script]# sh +x backmysql.sh

This backup MySQL successfully!


This article from "Fragrance Distant" blog, please be sure to keep this source http://5604671.blog.51cto.com/5594671/1614970

MySQL Automatic backup

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.