Home > Database > Mysql Tutorial > body text

mysql 简单批量备份多个库_MySQL

WBOY
Release: 2016-06-01 13:50:53
Original
1146 people have browsed it

bitsCN.com     #!/bin/bash
#This script is batch backup for mysql;
SQL_name='dbname1 dbname2 dbname3……dbnameN-1 dbnameN'
SQL_pwd='123456'
for i in $SQL_name
do
mysqldump -uroot -p$SQL_pwd $i > $i-$(date +%y-%m-%d-%H-%M)。sql
sleep 5
done
完整备份方案,将所有数据库备份后,进行打包压缩归档,同时删除原备份文件。
#!/bin/bash
SQL_name=''dbname1 dbname2 dbname3……dbnameN-1 dbnameN''   #数据库名称;
SQL_pwd='123456'                        #数据库密码;
SQL_path='/usr/local/mysql/bin'        #数据库命令目录;
BACKUP_tmp=/data/backup/tmp     #备份文件临时存放目录;
BACKUP_path=/data/backup           #备份文件压缩打包存放目录;
for i in $SQL_name
do
$SQL_path/mysqldump -uroot -p$SQL_pwd $i > $BACKUP_tmp/$i-$(date +%y-%m-%d-%H-%M)。sql
sleep 3
done
sleep 60
#将备份数据打包,并删除原备份文件;
tar --remove-files -cvzf $BACKUP_path/school-backup-$(date +%y-%m-%d)。tar.gz $BACKUP_tmp/* 2&>1 /dev/null
exit 0
bitsCN.com

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template