#DataBase vars
DB_NAME_LIST=(xxxxx xxxxx xxxxx xxxx) DB_USER="" DB_PASS="" DB_HOST=""#FTP varsFTP_UPLOAD_DIR="/QA/mysql_backup"FTP_HOST="172.16.10.241"FTP_USER="xxxxxxx"FTP_PASS="xxxxxxxx"# Others vars # whereis mysqldump # IS ` but not ' BIN_DIR="/usr/bin" BCK_DIR="/home/robot/mysql_backup" DATE=`date +%Y%m%d_%H%M%S` echo "Make a folder:" $DATEmkdir $BCK_DIR/$DATEfor DB_NAME in ${DB_NAME_LIST[@]}do echo "Backup DataBase:" $DB_NAME # TODO Backup MySQL #$BIN_DIR/mysqldump --opt -h$DB_HOST -u$DB_USER -p$DB_PASS $DB_NAME > $BCK_DIR/$DATE/$DB_HOST.$DB_NAME.dump.sql $BIN_DIR/mysqldump --defaults-extra-file=/etc/mysql/backup.cnf $DB_NAME > $BCK_DIR/$DATE/$DB_HOST.$DB_NAME.dump.sql #$BIN_DIR/mysqldump --login-path=local -e $DB_NAME > $BCK_DIR/$DATE/$DB_HOST.$DB_NAME.dump.sql echo "Finish Backup DataBase:" $DB_NAMEdone # TODO tar .sqlecho "#################################################################"echo "TAR the bakup folder"echo "#################################################################"tar -czvf $BCK_DIR/$DATE.tar.gz $BCK_DIR/$DATE# TODO Upgrade MySQL Backup to FTP echo "#################################################################"echo "Upgrade MySQL Backup to FTP"echo "#################################################################"ftp -v -n $FTP_HOST << EOFuser $FTP_USER $FTP_PASSbinaryhashcd $FTP_UPLOAD_DIRlcd $BCK_DIRpromptput $DATE.tar.gzbyeEOF# TOD remove Backup file and folderecho "Remove the backup folder and file " $DATE "and" $DATE.tar.gzrm -rf *$DATE*