#!/bin/sh
#mysql data backup script
clear
name=niyang
BakDir=/var/ftp/backup/
LogFile=/var/ftp/backup/log/mysqlbak.log
Data=game`date +%y%m%d%H`
Dumpfile=$Data.sql
GzDumpfile=$Data.sql.gz
echo "welcome to my program!"
echo "hell,$name ,you can backup now!"
echo " " >> $LogFile
echo "----------$name backup-----------" >> $LogFile
echo " " >> $LogFile
echo "---------------------------------------------" >> $LogFile
echo $(date +"%y-%m-%d %H:%M:%S") >> $LogFile
echo "--------------------------" >> $LogFile
cd $BakDir
mysqldump --quick --flush-logs --lock-all-tables database > $Dumpfile
echo "Dump Done!" >> $LogFile
tar zcvf $GzDumpfile $Dumpfile >> $LogFile 2>&1
echo "$GzDumpfile backup Success!" >> $LogFile
rm -f $Dumpfile
find $BakDir -mtime +10 exec rm -f {} \;
#find $BakDir -mtime +10 -delete
echo "Backup Done!"
ll -h $BakDir
echo "thank you for use this program , bye!"