#!/bin/bash
BACKUP_DIR=/data/backup
USER=root
PASSWD=root
mkdir $BACKUP_DIR
#|| 如果两个操作数中有任意一个非零,则条件为真。
[ -d $BACKUP_DIR ] || mkdir $BACKUP_DIR
while true;do
cat << EOF
please input a number to choice your back up tool:
1.mysqldump
2.xtrabackup
3.quit
EOF
read -p "Your choose: " choose
case "$choose" in
1)
mysqldump -u$USER -P$PASSWD -A -F -E -R --single-transaction --master-data=1 --flush-privileges --triggers --default-character-set=utf8 --hex-blob > $BACKUP_DIR/fullback_$(date +%F_%T).sql;;
2)
innobackupex --user=$USER --password=$PASSWD $BACKUP_DIR;;
3)
echo "Bye!" && exit 2;;
*)
echo "choose Error !" && exit 3;;
esac
done