MySQL Backup (i)

Source: Internet
Author: User
Tags mysql backup

One: Sub-library backup [[email protected] scripts] #cat  mysql_fenku_bak.sh #!/bin/sh#----------------------- ---------------------#Author:  created by randolph 2016-04#blog:http:// Randolph.blog.51cto.com#function: this scripts function is mysql backup#version : 4.1.2#---------------------------------------------bakpath=/optmyuser=rootmypass=666888socket=/data/3307/ mysql.sockmycmd= "mysql -u$myuser -p$mypass -s  $SOCKET" mydump= "Mysqldump -u$myuser  -p$MYPASS -S  $SOCKET  -x -b -f -r "[ ! -d  $BAKPATH  ]  && madir -p /optdblist= ' $MYCMD  -e  "show databases;" | egrep -vi  "Data|infor|mysql|perfor" ' for n in  $DBLISTdo           $MYDUMP   $n |gzip > $BAKPATH/${n}_$ (date +%f). Sql.gz done II: Backing up the database [email  protected] scripts] #cat   /server/scripts/mysql_back.sh    #!/bin/sh#--------------------------------------------#Author:  created by randolph 2016-04#blog:http://randolph.blog.51cto.com#function: this  scripts function is mysql backup#version:4.1.2#------------------------------------------- --#Define  path bakdir=/opt/bak_1/' date+%y-%m-%d ' #MYSQLDB = ' mysql-uroot -p ' 666888 '  -e  ' show databases; "| Grep -evi "Data|infor|mys|per" ' mysqlpw=666888mysqlusr=root#must use root userrun  scriptsif [  $UID  -ne 0 ] ;then    echo this script  must use the root user ! !!     sleep 2    exit 0fi#Define DIR andmkdir  dirif [ ! -d  $BAKDIR  ]; then    mkdir -p $ bakdirelse    echo this is&nbsp, $BAKDIR  exists....fi#Use mysqldumpbackup mysqlfor  dbname in  ' MySQL  -uroot -p ' 888888 '  -e  ' show databases; ' | Grep -evi "Data|infor|mys|per" ' do    /application/mysql/bin/mysqldump -u$ Mysqlusr-p ' 888888 '  --events -B  $dbname |gzip >/opt/bak_1/${dbname}_bak.gzdone#/ application/mysql/bin/mysqldump  -u$mysqlusr -p$mysqlpw -b# $MYSQLDB > $BAKDIR/mysql_ db.sql   echo  "The mysql backup successfully"


This article from "Randolph" blog, reproduced please contact the author!

MySQL Backup (i)

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.