I've read a bunch of articles on taking consistent backups of mySQL, including What's the meaning of consistent dataset? (MySQL), but I still don't think I know enough to answer this question with confidence. I originally posted this question on stackoverflow, but was advised by a couple of high-reputation members that this would be a better place for it. So I'm basically copy-pasting the question here and deleting it from there. Hope that's an acceptable practice - I asked for help on how to go about moving the question, but didn't get any.

Running MySQL 5.5 using only InnoDB tables with file-per-table enabled backing a multi-user website hosted on Amazon EC2 running Amazon Linux.

From what I've been able to find here and other Stack Exchange sites, it sounds like it's okay to copy the whole data tree to make a valid backup after shutting down the server.

What I'm currently doing for backups is:

  1. stop apache
  2. stop mysql
  3. take lvm2 snapshot of the volume containing the data directory
  4. start mysql
  5. start apache
  6. use rsnapshot to copy the lvm2 snapshot to a different volume
  7. delete the lvm2 snapshot

In his answer to https://stackoverflow.com/questions/9165118/lvm-mysql-backup/9165604#9165604, Bill Karwin noted that lvm snapshots can seriously degrade I/O performance. But I believe that since the lvm snapshot is only active for the short time it takes rsnapshot (which uses rsync) to complete, performance shouldn't be seriously impacted.

So my question is whether I really need to stop the servers while taking the lvm snapshot. I think I read somewhere that although an "instant in time" snapshot could catch InnoDB tables with incomplete transactions, that if that happens mySQL will deal with them consistently when started again. So I'm thinking that stopping the server might be overkill, even though it's only stopped for a very short time while the lvm snapshot is taken. (I first stop apache so requests can't come in without a database running).

I'll certainly check out Bill's advice on http://www.percona.com/software/percona-xtrabackup. And it seems to get cited a lot here. Does it work well with MySQL 5.5, or do I need to install Percona Server? In the meantime, I'd like to know if I can make an incremental improvement to what I'm doing - or if what I'm doing is already broken!

  • 2
    Does the anonymous downvote mean that I shouldn't have moved the question here, that the process I used for moving it here was flawed, or does it mean there's something wrong with the question? If you don't give me any clue how to be a better member of the community, I'm not likely to improve. – sootsnoot Dec 25 '14 at 4:19
  • Seems like a perfectly valid and well-stated question to me. – Andrew Schulman Dec 26 '14 at 1:16

TL;DR : Stopping your services is not necessary with LVM snapshots. +1 for XtraBackup.

It is not required to stop the services. The LVM snapshot is equivalent to pulling the power, which means it is consistent, but the same as a crash. When starting the service from one of your backups, it will have to do crash recovery. The time needed to do this varies depending on the size of your InnoDB log files but can be several minutes. Once the crash recovery has completed, your service will be up and running again normally.

By shutting down services before the snapshot, your recovery will start faster but at the cost of some downtime every time you run your backups. Also worth considering is that every time you stop services, you lose all the warm buffer pool, so you will also incur some performance degradation from having to read data into memory again.

XtraBackup is designed to work with Oracle MySQL as well as Percona Server. It's a good option, though as with all things backup, test, test, and test it again to make sure it works before you find out you need it.

  • Okay, this is exactly the kind of stuff I wanted to know: if stopping the server for the snapshot isn't actually necessary, what is the cost/benefit tradeoff. I think what I should do is drop the stop/restart immediately (which also loses the OPCode cache), and also pursue XtraBackup, perhaps doing both for a while and comparing performance, and testing restores. I'll mark this as the accepted answer in a couple of days, assuming nobody disputes it :-) – sootsnoot Dec 25 '14 at 5:19
  • The answer contains helpful details and nobody has refuted it. So I reckon I should accept it :-) – sootsnoot Dec 29 '14 at 3:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.