Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed snap to dump master status.

  • Loading branch information...
commit 17e8250f559e3316e02b1d9966fa758cc8ae2531 1 parent c216600
@dotmanila authored
Showing with 6 additions and 2 deletions.
  1. +6 −2 lvmsnap.sh
View
8 lvmsnap.sh
@@ -12,7 +12,8 @@ MYSQLLV=mysql-data
MYSQLDD=/mysql/data
# Temporary file
TMPFILE=/tmp/lvmsnap-$$.tmp
-
+# Binary logs directory
+BLOGDIR=/mysql/logs
# Commands are snapshot, merge, list
CMD=$1
RESTRSNAP=$2
@@ -20,6 +21,7 @@ RESTRSNAP=$2
function trim {
echo 'Trimming excess snapshots .. '
lvs --noheadings -o lv_path|grep 'sb/mysql-data-'|head -n-4|awk '{print $1}'|xargs lvremove -f
+ ls $BLOGDIR|grep 'mysql-data-'|head -n-4|xargs rm -rf
echo 'done'
echo
lvs
@@ -28,9 +30,11 @@ function trim {
function snap {
echo 'Taking a new snapshot .. '
+ snap="$MYSQLLV-`date +%Y%m%d%H%M`"
mysql <<EOD
FLUSH TABLES WITH READ LOCK;
-\! lvcreate --size=$SNAPSZE --snapshot --name $MYSQLLV-`date +%Y%m%d%H%M` /dev/${MYSQLVG}/${MYSQLLV}
+\! mysql -e 'SHOW MASTER STATUS' > $BLOGDIR/${snap}-binlog-info
+\! lvcreate --size=$SNAPSZE --snapshot --name $snap /dev/${MYSQLVG}/${MYSQLLV} > /dev/null 2>&1
UNLOCK TABLES;
EOD
echo 'done'
Please sign in to comment.
Something went wrong with that request. Please try again.