title: How to write the Mysql binary log position of master when doing a mysqldump from slave?
body: <p>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.</p>
  
  <p>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.</p>
  
  <p>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:</p>
  
  <ul>
  <li>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)</li>
  <li>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;" (<a href="http://dev.mysql.com/doc/refman/5.0/en/mysqldump.html" rel="noreferrer">http://dev.mysql.com/doc/refman/5.0/en/mysqldump.html</a>).  But this isn't going to do us any good unless we know in advance we want to back something up from the salve.</li>
  <li>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.</li>
  </ul>
  
  <p>This seems like something common enough that somebody must have figured out before, hopefully that somebody is using Stack Overflow?</p>