最新消息: 新版网站上线了!!!

MySQL备份脚本

#!/bin/bash

time=`date +%Y%m%d%H`

backupdir=/home/mysqlbak/$time

mkdir -p $backupdir

chmod 0777 $backupdir

arr=("table1" "table2" "table2")

for name in ${arr[@]}

do

   /usr/local/mysql/bin/mysqldump -h localhost  -uroot  -p123456 --opt  database $name  > $backupdir/$name.sql

done

 

tar cvjf $backupdir/../$time.tar.bz2 $backupdir > /dev/null 2>&1

rm -rf $backupdir/*.sql

mv  $backupdir/../$time.tar.bz2 $backupdir/backup.tar.bz2

 
.....

转载请注明:谷谷点程序 » MySQL备份脚本