#!/bin/bash
backdir=/home/shaowei/dbbak
dbuser=‘dbusername‘
dbpass=‘dbpasswd‘
dblist=$(ls -p /var/lib/mysql | grep / | tr -d /)
today=$(date +%Y%m%d)
mkdir $backdir
mkdir $backdir/$today
for dbname in $dblist
do mysqldump -u$dbuser -p$dbpass $dbname | gzip -v > $backdir/$today/$dbname-$today.sql.gz
echo $dbname ‘OK‘
done
Mysql数据库导出压缩并保存到指定位置备份脚本,布布扣,bubuko.com
时间: 2024-10-27 07:23:18