MySQL Sub-library backup split color platform to build backup data

Source: Internet
Author: User
Tags mkdir

Split color platform to build sub-Library
Enterprise: 217 1793 408
[email protected] scripts]# cat backup_database.sh

#!/bin/bash
Mysql_user=root
mysql_pass=123456
Mkdir-p/backup
for n in mysql -u$mysql_user -p$mysql_pass -e ‘show databases;‘ 2>/dev/null|grep -Ev ‘_schema|mysql‘|sed ‘1d‘ ;
Do
Mysqldump-u$mysql_user-p$mysqlpass-b $n 2>/dev/null>/backup/${n} date +%Y_%m_%d . sql
Done

Sub-database sub-table

[email protected] scripts]# cat backup_tables.sh
#!/bin/bash
Mysql_user=root
mysql_pass=123456
Mkdir-p/backup
for n in mysql -u$mysql_user -p$mysql_pass -e ‘show databases;‘ 2>/dev/null|grep -Ev ‘_schema|mysql‘|sed ‘1d‘ ;
Do
Mkdir-p/backup/$n
for M in mysql -u$mysql_user -p$mysql_pass $n -e "show tables;" 2>/dev/null|sed ‘1d‘ ;
Do
Mysqldump-u$mysql_user-p$mysqlpass $n $m 2>/dev/null>/backup/${n}/${m} date +%Y_%m_%d . sql
Done
Done

MySQL Sub-library backup split color platform to build backup data

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.