! # / bin / the bash BACK_TIME = DATE + `"%% F-H ":% M:% S '# backup script timestamp, may also be used $ {date +"% F-% H ":% M:% } S the USER = the root the PASS = CentOS dATABASE MySQL -u = `$ $ the PASS the USER -p -e 'Show databases' | -ev grep '^ (database | INFORMATION_SCHEMA | performance_schema) $' #` the fixed database in addition to those of outside of the backup. $ DATABASE in DB for; do MYDIR = / Data / Backup / $ db`date% +% F-H ' [! -d $ MYDIR] && mkdir -p $ # {} is determined MYDIR directory does not exist is true, creating backup directory. Note: If you remove! , Is that there is really a mysqldump -u $ PASS the USER -p $ -B $ db | gzip> $ MYDIR / $ {db} _ $ BACK_TIME.sql.gz DONE