mysqldump备份多个数据库实例,数据量小的情况
备份脚本:
#!/bin/bash ####time## date=`date "+%Y%m%d-%H%M%S"` for item in $(cat /home/work/database/databases.txt); do GameName=`echo $item | awk -F"," '{print $1}'` database_name=`echo $item | awk -F"," '{print $2}'` database_host=`echo $item | awk -F"," '{print $3}'` mysql_user='root' mysql_pwd='password' ######### mysqlback_root='/home/vsftp/db' #####mysqldump#### /usr/bin/mysqldump -h${database_host} -u${mysql_user} -p${mysql_pwd} --single-transaction --master-data=2 -B ${database_name} > ${mysqlback_root}/${GameName}_${date}_${database_name}.sql done cd ${mysqlback_root} && find . -type f -ctime +7 |xargs -i rm -rf {}