#!/bin/bash
cd /data/backup/
/usr/local/mysql/bin/mysql -h 127.0.0.1 -u root -pxxxx -e "FLUSH TABLE WITH READ LOCK;"
if [ $? = 0 ] ;then
/usr/bin/innobackupex --user=root --password=chinasnto@123 --defaults-file=/etc/my.cnf --stream=tar /data/backup/ 2>`date +%F`.log | gzip 1>`date +%F`.tar.gz
else
exit 0
fi
/usr/local/mysql/bin/mysql -h 127.0.0.1 -u root -pxxxx -e "unlock tables;"
cd /data/backup/
file = "/data/backup/`date +%F`.tar.gz"
if [ ! -f "$file" ] ;then
rsync -av --progress --password-file=/etc/rsyncd.global --port=1873 /data/backup/ [email protected]::globalhome/
else
exit 0
fi
rm /data/backup/$file -f