Welcome to shoot bricks. The details are as follows: # MYSQL data File Path MYSQL_DATA_PATH = "/usr/local/mysql/data/" # Backup Directory MYSQL_DUMP_PATH = "***/DB/" # backup username MYSQL_ACCOUNT = "mysql_backup "# backup password MYSQL_PASSWORD = "mysql_backup" MYSQLDUMP_OPTS = "mysqldump-u $ MYSQL_ACCOUNT-p $ MYSQL_PASSWORD -- single-transaction" # The compression command bzip2-k retains the source file TAR_OPTS = "bzip2 "# back up function BackDB () {FULLPATH = "$1" # traverse the directory for dbName in $ (/bin/ls $ FULLPATH) do # check is da Tabase fileType = '/usr/bin/file $ FULLPATH $ dbName |/bin/awk' {FS = ": "} {printf $2}'' # The folder type is directory if ["directory" = $ fileType]; then # start dump if ["$ dbName" = "mysql"] \ | ["$ dbName" = "test"] \ | ["$ dbName" = "information_schema"] \ | ["$ dbName" = "cece_schema"]; then echo "-------------> $ dbName not need dump !! "Else echo $ dbName www.2cto.com dumpName = $ MYSQL_DUMP_PATH/" $ dbName "_" $ DATESTR "$ MYSQLDUMP_OPTS $ dbName>" $ dumpName ". SQL # compressing the backup file $ TAR_OPTS "$ BACKUP_NAME ". SQL fi else printf '% s is not database ######## \ n' $ dbName fi done} # Back up function BackDBTB () for each data table () {FULLPATH = "$1" # traverse the directory for fName in $ (/usr/bin/find $ FULLPATH-name "*. ibd ") do dbPath = 'echo" $ fName "|/bin/awk 'in in {FS =" '$ fullpath' "} {printf $2} ''# get database name dbName = 'echo" $ dbPath "|/bin/awk 'in in {FS ="/"} {printf $1}'' # get table name tbName = 'echo "$ dbPath" |/bin/awk 'in in {FS = "/"} {printf $2} ''# start dump if [" $ dbName" = "mysql"] \ | ["$ dbName" = "test"] \ | ["$ dbName" = "information_schema"] \ | ["$ dbName "=" performance_schema "]; then echo "-------------> $ dbName not need dump !! "Else echo $ dbName $ tbName dumpName = $ MYSQL_DUMP_PATH/" $ dbName "_" $ tbName "_" $ DATESTR "$ MYSQLDUMP_OPTS $ dbName $ tbName>" $ dumpName ". SQL # compressing the backup file $ TAR_OPTS "$ dumpName ". SQL fi done} By babaoqi