An argument for using mysqldump

I fully agree with Morgan’s An argument for not using mysqldump. This post does not come to contradict it, but rather shed a positive light on mysqldump.

I usually prefer an LVM snapshot based backup, or using XtraBackup. And, with databases as large as dozens of GB and above, I consider mysqldump to be a poor alternative. Poor in runtime, poor in overhead while taking the backup.

However once in a while I get to be reminded that mysqldump just works.

As a recent example, I had a server which was killed after an ALTER TABLE statement hanged forever (table already ALTERed, but old scheme never dropped). The old table data still hanged around the file system, but was not recognized by InnoDB. Trying out DISCARD TABLESPACE did not do the job, and eventually file was dropped.

So far, reasonable. InnoDB would complain about some table it never recognized in the first place, but all would work. That is, until backup was concerned. With innobackup or XtraBackup the restore would fail on some internal problem. LVM would work, but would only copy+paste the problem: innobackup would never again be able to be used on this database.

It turned out a 120GB InnoDB compressed data (roughly 250GB uncompressed) would dump in –single-transaction in a matter of 4 hours and would restore in a matter of some 20 hours. A whole lot more than the 3 hours total it would take for an LVM backup for that database. But the data would load well; no missing tablespaces.

I’ve had similar incidents in the past. Not to mention the issue of compressing shared tablespace file.

There’s something about being able to say “I’m not sure how long this is going to take; maybe a day or two. But in the end, we will have problems P1, P2 & P3 resolved“.

I like the clean state you get from a mysqldump restore.

9 thoughts on “An argument for using mysqldump

  1. @Daniël – nope. Maybe with MySQL cluster, but with InnoDB and MyISAM the endianess doesn’t matter. There’s even a MySQL certificate question to that effect. You just need:

    – two’s-complement signed integers
    – IEEE floating-point math

    This is true for most hardware except for perhaps embedded.

    NDB has it’s own backup, which I would use in favor of mysqldump.

  2. Morgan,

    “…A lot of this issue probably comes from actually *running mysqldump*…”
    Not sure what you meant, but I was referring to three distinct incidents I had, where innobackup/xtrabackup failed on backup. In two cases, it was (probably) because of tables unlisted in the data dictionary.
    Either the backup would fail (consistently) halfway through, or the restore would fail halfway through.
    On another case I would get (consistently) duplicate key errors on replication slave set up with innobackup (granted, this was almost 2 years ago).

    Just so no one gets me wrong, what I’m saying is:
    – XtraBackup is a great tool and I’m using it a LOT. Customers are always surprised to find out how easy it is to take a hot backup.
    – It is susceptible to bugs, either withing the backup code itself, as well as to InnoDB code, or inconsistencies within file system.
    – LVM based backups, while not as lightweight as XtraBackup in my experience, are not susceptible to such bugs.
    – mysqldump just works, with the intolerable runtimes on large data sets.

  3. I am couple years late to this conversation, but the technique I used to speed up mysqldump was to backup tables by groups, and run them simultaneously. If I had 1K tables, I would split them into group of 50 tables (where a group has at least one of the largest tables), process them in parallel by piping to gzip. Couple hundred Gs in 30 minutes.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.