Mysql数据库备份脚本(使用mysqldump)
Mysql(mysqldump)备份脚本 记录下服务器上一个备份 mysql 数据库的脚本,使用 mysql 自带的mysqldump命令 !/usr/bin/env bash USER=username PASSWORD=password MAXIMUM_BACKUP_FILES=10 BACKUP_FOLDER=/path/to/save/folder DATABASES=( db_name_0 db_name_1 ) # check mysqldump instlled _=$(command -v mysqldump) if [[ $? != 0 ]] then printf "You don't seem to mysqldump installed, exit..\n" exit 1 fi # create backup folder if [ ! -d $BACKUP_FOLDER ] then mkdir $BACKUP_FOLDER fi # backup for DB in ${DATABASES[@]} do echo backing up ${DB} database ... if $(mysqldump --host=localhost --user=${USER} --password=${PASSWORD} ${DB} | gzip -9 > ${BACKUP_FOLDER}/db_${DB}_$(date +"%Y%m%d")....