diff options
author | Alexander Sulfrian <alexander@sulfrian.net> | 2010-02-02 06:16:41 +0100 |
---|---|---|
committer | Alexander Sulfrian <alexander@sulfrian.net> | 2010-02-02 06:16:41 +0100 |
commit | 2da1c4ee2d9825d764337758819c6f45308cc4dd (patch) | |
tree | 0af3815e0b7c401a792051ea2352fbfa12f5f779 | |
parent | 6f460e45a2606167a54bb8dbc718da001d7663b5 (diff) | |
download | backup-2da1c4ee2d9825d764337758819c6f45308cc4dd.tar.gz backup-2da1c4ee2d9825d764337758819c6f45308cc4dd.tar.xz backup-2da1c4ee2d9825d764337758819c6f45308cc4dd.zip |
changed master.info file handling to show slave status;
-rwxr-xr-x | mysql/mysql_backup.sh | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/mysql/mysql_backup.sh b/mysql/mysql_backup.sh index 689fb70..205d4d9 100755 --- a/mysql/mysql_backup.sh +++ b/mysql/mysql_backup.sh @@ -43,7 +43,9 @@ echo | _log # flush logs on master # get master -MYSQL_MASTER=$(sed -n '4p' /var/lib/mysql/master.info) +MYSQL_MASTER=$(mysql -h${MYSQL_SERVER} -u${MYSQL_USER} \ + -p${MYSQL_PASSWORD} <<< "SHOW SLAVE STATUS\G" | \ + grep "^ *Master_Host:" | awk '{ print $2 }') echo "flush logs;" | mysql -h${MYSQL_MASTER} -u${MYSQL_USER} \ -p${MYSQL_PASSWORD} @@ -62,8 +64,12 @@ MYSQL_DATABASES=$(mysqlshow -h${MYSQL_SERVER} -u${MYSQL_USER} \ '1d') # get binlog position -MYSQL_BINLOG=$(sed -n '2p;3p' /var/lib/mysql/master.info | while read i - do echo -n "-$i" ; done) +MYSQL_BINLOG="-"$(mysql -h${MYSQL_SERVER} -u${MYSQL_USER} \ + -p${MYSQL_PASSWORD} <<< "SHOW SLAVE STATUS\G" | \ + grep "^ *Master_Log_File:" | awk '{ print $2 }')"-"$( \ + mysql -h${MYSQL_SERVER} -u${MYSQL_USER} \ + -p${MYSQL_PASSWORD} <<< "SHOW SLAVE STATUS\G" | \ + grep "^ *Read_Master_Log_Pos:" | awk '{ print $2 }') # backup all databases to file for db in ${MYSQL_DATABASES} |