#!/bin/bash cd /root/bkuptest/Backup if tar -ixvf test.tar then /etc/init.d/mysqld stop /bin/sleep 20 if ps awux | grep -v grep | grep mysqld then exit $? else echo "mysql stopped" fi if rm -rf /var/lib/mysql/* then echo "remove done" if /usr/bin/innobackupex-1.5.1 --copy-back /root/bkuptest/Backup/ then echo "copy back done" if chown -R mysql:mysql /var/lib/mysql then echo "permission Done" /bin/sleep 20 /etc/init.d/mysqld start /bin/sleep 20 if ps awux | grep -v grep | grep mysqld then echo "mysql started" else exit $? fi if /usr/bin/innobackupex-1.5.1 --apply-log --user=root --password=testpassword /root/bkuptest/Backup/ then echo "applying log done" if rm -rf /root/bkuptest/Backup/* then echo "removing done" exit $? else echo "failed removing backup" | mail -s "[Backup] remote.backup.com Failed Backup " ketan@email.com exit $? fi else echo "Failed applying log" | mail -s "[Backup] remote.backup.com Failed Backup " ketan@email.com exit $? fi else echo "Failed setting up permission" | mail -s "[Backup] remote.backup.com Failed Backup " ketan@email.com exit $? fi else echo "Filed on Copy Back" | mail -s "[Backup] remote.backup.com Failed Backup " ketan@email.com exit $? fi else echo "Failed Removing Mysql Files" | mail -s "[Backup] remote.backup.com Failed Backup " ketan@email.com exit $? fi fi else echo "Failed everything on destination" | mail -s "[Backup] remote.backup.com Failed Backup " ketan@email.com fi