#!/bin/bash MYUSER=root MYPASS=password SOCKET="/var/lib/mysql/mysql.sock" MYCMD="mysql -u $MYUSER -p$MYPASS" MYDUMP="mysqldump -u $MYUSER -p$MYPASS" BACKUP_DIR="/work/backup/mysql" for database in `$MYCMD -e "show databases;"|sed ‘1,2d‘ |egrep -v "mysql|schema"` do if [ ! -f $BACKUP_DIR/${database} ]; then mkdir -p $BACKUP_DIR/${database} fi $MYDUMP ${database} |gzip > $BACKUP_DIR/${database}/${database}_`date +%F`.tar.gz done
本文出自 “Smurf Linux运维” 博客,请务必保留此出处http://jin771998569.blog.51cto.com/2147853/1639712
原文地址:http://jin771998569.blog.51cto.com/2147853/1639712