0

I am writing a script to snapshot EBS volumes on AWS. One of the volumes contains the data for a mysql database. I am aware that I need to somehow stop data being written to the database while the snapshot is initiated so that the data is consistent but I cannot obtain a lock on all the tables on the database.

Will using xfs_freeze without a lock on the tables suffice for a consistent solution?

Ty

mrwooster
  • 243
  • 3
  • 7

1 Answers1

0

no, because mysql might still have data in it's own buffers, that the filesystem couldn't possibly know about.

the proper method is to "flush tables with read lock", THEN create a filesystem snapshot, after which you can immediately release the lock again.

why can't you obtain a lock?

r00t
  • 321
  • 1
  • 2
  • @r001 I am trying to do all this in PHP ;) and its not very easy to get a lock on all tables in the database. – mrwooster Dec 21 '10 at 08:18
  • @mrwooster Sure it is. In PHP, `mysqli_query("FLUSH TABLES WITH READ LOCK");` then take the snapshot by using `exec()` then `mysqli_query("UNLOCK TABLES");` It's actually very easy. – utdrmac Dec 02 '18 at 06:00