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