16. mysql Database sub-Library sub-table backup script

Source: Internet
Author: User
Tags mkdir

MySQL Database sub-Library sub-table backup script

=================== students to share the sub-database sub-table ==========================

The difference between a script single double quote:

Single quotes are strong references, forcing output is WYSIWYG.

Double quotes are parse variables and multiple strings, numbers, etc. concatenate a string


Condition 1 | | Condition 2 or fake true or false

Condition 1 && Condition 2 and True or False

! Condition 1 && Condition 2 true and False


[Email protected] backup]# cat/server/scripts/mysqldump1.sh

#!/bin/sh

User=root

Passwd=oldboy

Socket=/data/3306/mysql.sock

login= "Mysql-u$user-p$passwd-s $SOCKET"

database=$ ($LOGIN-E "show databases;" | Egrep-v "*chema|mysql" |sed ' 1d ')

dump= "Mysqldump-u$user-p$passwd-s $SOCKET"

For database in $DATABASE

Do

table=$ ($LOGIN-E "use $database; show tables;" | Sed ' 1d ')

For table in $TABLE

Do

[-d/server/backup/$database] | | Mkdir-p/server/backup/$database

# [-d/server/backup/$database] && mkdir-p/server/backup/$database

$DUMP $database $table |gzip >/server/backup/$database/${database}_${table}_$ (date +%f). sql.gz

Done

Done

650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M02/9D/D6/wKiom1mHJcHDnPMqAACvPkwGYg8504.png "title=" Image.png "alt=" Wkiom1mhjchdnpmqaacvpkwgyg8504.png "/>

=============================================================

16. mysql Database sub-Library sub-table backup script

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.