Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 391413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T16:03:33+00:00 2026-05-12T16:03:33+00:00

I am currently running mysqldump on a Mysql slave to backup our database. This

  • 0

I am currently running mysqldump on a Mysql slave to backup our database. This has worked fine for backing up our data itself, but what I would like to supplement it with is the binary log position of the master that corresponds with the data generated by the mysqldump.

Doing this would allow us to restore our slave (or setup new slaves) without having to do a separate mysqldump on the main database where we grab the binary log position of the master. We would just take the data generated by the mysqldump, combine it with the binary log information we generated, and voila… be resynced.

So far, my research has gotten me very CLOSE to being able to accomplish this goal, but I can’t seem to figure out an automated way to pull it off. Here are the “almosts” I’ve uncovered:

  • If we were running mysqldump from the main database, we could use the “–master-data” parameter with mysqldump to log the master’s binary position along with the dump data (I presume this would probably also work if we started generating binary logs from our slave, but that seems like overkill for what we want to accomplish)
  • If we wanted to do this in a non-automated way, we could log into the slave’s database and run “STOP SLAVE SQL_THREAD;” followed by “SHOW SLAVE STATUS;” (http://dev.mysql.com/doc/refman/5.0/en/mysqldump.html). But this isn’t going to do us any good unless we know in advance we want to back something up from the salve.
  • If we had $500/year to blow, we could use the InnoDb hot backup plugin and just run our mysqldumps from the main DB. But we don’t have that money, and I don’t want to add any extra I/O on our main DB anyway.

This seems like something common enough that somebody must have figured out before, hopefully that somebody is using Stack Overflow?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T16:03:34+00:00Added an answer on May 12, 2026 at 4:03 pm

    The following shell script will run in cron or periodic, replace variables as necessary (defaults are written for FreeBSD):

    # MySQL executable location
    mysql=/usr/local/bin/mysql
    
    # MySQLDump location
    mysqldump=/usr/local/bin/mysqldump
    
    # MySQL Username and password
    userpassword=" --user=<username> --password=<password>"
    
    # MySQL dump options
    dumpoptions=" --quick --add-drop-table --add-locks --extended-insert"
    
    # Databases
    databases="db1 db2 db3"
    
    # Backup Directory
    backupdir=/usr/backups
    
    # Flush and Lock
    mysql $userpassword -e 'STOP SLAVE SQL_THREAD;'
    
    set `date +'%Y %m %d'`
    
    # Binary Log Positions
    masterlogfile=`$mysql $userpassword -e 'SHOW SLAVE STATUS \G' | grep '[^_]Master_Log_File'`
    masterlogpos=`$mysql $userpassword -e 'SHOW SLAVE STATUS \G' | grep 'Read_Master_Log_Pos'`
    
    # Write Binlog Info
    echo $masterlogfile >> ${backupdir}/info-$1-$2-$3.txt
    echo $masterlogpos >> ${backupdir}/info-$1-$2-$3.txt
    
    # Dump all of our databases
    echo "Dumping MySQL Databases"
    for database in $databases
    do
    $mysqldump $userpassword $dumpoptions $database | gzip - > ${backupdir}/${database}-$1-$2-$3.sql.gz
    done
    
    # Unlock
    $mysql $userpassword -e 'START SLAVE'
    
    echo "Dump Complete!"
    
    exit 0
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.