#!/bin/sh
DUMPDIR=xxx
DATE=`date '+%Y%m%d-%H%M'`
cd $DUMPDIR
#單表備份
#mysqldump -uxxx -pxxx --single-transaction --default-character-set=utf8 db table > xxx.sql
#vsdb全庫備份
mysqldump -uxxx -pxxx --single-transaction --default-character-set=utf8 db > xxx.sql
if [[ $? == 0 ]];then
mv *.tar bak
tar czf $DATE.tar xxx.sql
if [[ $? == 0 ]];then
rm -f bak/*.tar
else
mv bak/*.tar ./
fi
fi
rm -f xxx.sqlmysql