MySQL Backup

From Hashmysql
Jump to: navigation, search

It has been asked a few times "How do I back up all databases using mysqldump?" The answer to that is mysqldump -all-databases, not a big stretch. However a follow up question occasionally asked "Can I get that as one file per database?" Well, not from mysqldump directly. But I have kludged together two scripts which others have found useful:

  o File per Schema -- Each schema (database) is put in a file of its own.
  o File per Table --  Each table is put in a file of its own, in a directory 
                       named after the schema (database)

It should be noted that *neither* of these are useful to making a backup of a live system. If there is other activity on the server these will not guarantee a consistent backup. These are for working with data when you have full control over the server.