MySQL database sub-Library backup script
version 1
For dbname in ' mysql-uroot-poldboy123-e ' show databases; "|grep-evi" database|informa|perfor "'
Do
mysqldump-uroot-poldboy123--events-b $dbname |gzip >/opt/bak/${dbname}_bak.sql.gz
Done
version 2
#!/bin/bash
Myuser=root
Mypass=oldboy123
mycmd= "Mysql-u$myuser-p$mypass--default-character-set=utf8"
mydump= "Mysqldump-u$myuser-p$mypass--default-character-set=utf8--events-b"
Dblist= ' $MYCMD-e "show databases; | Grep-evi "Database|informa|perfor"
[!-d/opt/bak] && mkdir-p/opt/bak
For dbname in $DBLIST
Do
$MYDUMP $dbname |gzip >/opt/bak/${dbname}_bak.sql.gz
Done
Multi-instance sub-library backup
#!/bin/bash
Myuser=root
Mypass=oldboy123
Socket=/data/3306/mysql.sock
mycmd= "Mysql-u$myuser-p$mypass--default-character-set=utf8-s $SOCKET"
mydump= "Mysqldump-u$myuser-p$mypass--default-character-set=utf8-s $SOCKET--events-b"
Dblist= ' $MYCMD-e "show databases; | Grep-evi "Database|informa|perfor"
[!-d/opt/bak] && mkdir-p/opt/bak
For dbname in $DBLIST
Do
$MYDUMP $dbname |gzip >/opt/bak/${dbname}_bak.sql.gz
Done
MySQL Database sub-Library backup script