#!/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