Skip to content

Instantly share code, notes, and snippets.

@asvignesh
Created November 28, 2017 06:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asvignesh/cb0adc4259b675906d97dfda9ea8ef62 to your computer and use it in GitHub Desktop.
Save asvignesh/cb0adc4259b675906d97dfda9ea8ef62 to your computer and use it in GitHub Desktop.
Pre and Post script for MySQL server consistent* backup
#!/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
#!/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