Created
November 28, 2017 06:48
-
-
Save asvignesh/cb0adc4259b675906d97dfda9ea8ef62 to your computer and use it in GitHub Desktop.
Pre and Post script for MySQL server consistent* backup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
mysql -u <user> -p<Password> -e 'unlock tables;' | |
if [ $? -gt 0 ]; then | |
echo "Failed running mysql unfreeze" | |
exit 1 | |
else | |
echo "success" | |
exit 0 | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo ”Applying read lock and retaining the lock for 10 seconds ” | |
nohup mysql -u <user> -p<Password> -e 'flush tables; | |
flush tables; | |
flush tables with read lock; | |
set global read_only=1; | |
do sleep(10);' > foo.out 2> foo.err < /dev/null & | |
if [ $? -gt 0 ]; then | |
echo "Failed freezing db" | |
exit 1 | |
else | |
echo "successfully freezed for 10 secs" | |
exit 0 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment