6

I see in the documentation that the database backup tools are divided into four categories: hot backups, cold backups, physical backups and logical backups.

I understand the the most important difference between cold and hot backup is that the latter can be done while the database is operating and receiving read&write queries (and the result will be consistent and atomic).

But then, how do I know if mysqldump has this "hot" aspect or "cold" aspect? The documentation just places it in the logical backup category and is not 100% clear about this (yes, it seems to mention that it uses the same snapshot of the DB at the beginning of the mysqldump procedure, which suggests it's definitely a HOT backup tool, but just wanted to double check here).

The tables use InnoDB engine.

  • My original answer (now deleted) was wrong - using XtraBackup for years - mysqldump can be used for hot backups - confusion over --single-transaction and --lock-tables. Memo to self - double check your research. I corrected it and have added it along with the other (I hope) useful material. – Vérace Jun 29 '16 at 5:14
5

First of all, categorizing the backup into the four mentioned categories is not accurate. You can categorize into (hot, warm, cold), and into (physical, logical). In other words, the backup can be cold and physical, or, hot and physical, etc. It cannot be (physical and logical).

Notice please that physical backup is better called "Raw backup", which is a copy of the data files, and other related file, at filesystem level.

mysqldump is logical, i.e. it produces the statements that re-create the DB and/or the tables and/or the data, etc. Therefore it is not "physical"

"Hot Backup" means that the backup can happen without affecting the users, and without taking the application or DB server down, AND, the resulting backup is consistent. There are different strategies and tools to make hot backups. Sometimes, it is conditional to the storage engines you use.

To answer your question: mysqldump is not hot backup tool by default. This is especially true if you are using MyISAM among other engines, and/or tables are being locked during the backup.

But if your tables are pure InnoDB, and you use the --single-transaction option with mysqldump, then, yes, it would be considered hot.

HTH

| improve this answer | |
  • 1
    Thank you knocte for editing the answer, but I wanted it to stay " mysqldump is not hot backup tool" as it is THE answer, so I rolled back your editing. – Jehad Keriaki Jun 29 '16 at 2:24
  • 1
    you cannot say "X is not Foo", and then say, when using "X with --bar, then X is Foo", that's why I corrected it, you're contradicting yourself – knocte Jun 29 '16 at 6:02
4

From here, the complete command for a hot backup of a MySQL database using only InnoDB tables is:

mysqldump -u user -ppass --single-transaction --routines --triggers --all-databases > backup_db.sql

Note the gap between -u and user and the lack of a gap between -p and pass. This is correct - a quirk of MySQL which has caught me on more than one occasion.

This MySQL page also has a very clear and concise explanation of the difference between physical and logical backups.

Physical backups (also called raw):

Physical backups consist of raw copies of the directories and files that store database contents. This type of backup is suitable for large, important databases that need to be recovered quickly when problems occur.

This either involves shutting down the database or doing some sort of locking in order to prevent the database from changing during the process, and then taking a copy of the bits on disk.

Any updates are impossible during the process, unlike checkpointing (see below) where the database is "suspended" at a given point and then updates may proceed from that point while the backup is taken at the checkpoint.

The physical files (bits on disk) that make up the database are the ones that get backed up in a physical backup.

Read the page for more detail.

Logical backups:

Logical backup methods have these characteristics:

• The backup is done by querying the MySQL server to obtain database structure and content information.

What this basically means is that instead of being a binary bit for bit copy of the database at a given instant, this form of copy is a file consisting of the SQL that would be required to be run in order to reconstitute the database. Check out the contents of a mysqldump file (which is plain text, readable in any editor or using more/cat - what have you).

Hot v. Cold, or as the MySQL page calls them, Online v. Offline.

Hot - online - means that the server continues operating, Cold - offline - means that the database is not available for processing queries. With a hot backup however, there is a performance penalty to pay and that is why they are normally scheduled for off-peak times.

Again, I refer to the MySQL manual page for more detail (this page is one of the best written, clear and concise pieces of technical writing that I have come across in a long time).

You can read further there about Full v. Incremental backups and Snapshots. Come back here if you have further questions about these.

If you require a recommendation, I would recommend Percona's XtraBackup. It is a genuine hot backup solution for MySQL databases which use InnoDB tables - it does not work for the other engines, in particular MyIsam. The MyIsam architecture precludes hot backups - it requires locking of the database.

Finally, you might like to browse this post (author yours truly :-) ) which provides more detail on non-MySQL solutions to server backups.

| improve this answer | |
  • Good. But I don't understand why you deleted the old and added a new answer. You know you can edit an answer, right? ;) – ypercubeᵀᴹ Jun 29 '16 at 8:06
0

Yes it is a hot backup.

  • It is run with the database online, queries operating etc
  • The dump will be consistent and atomic - a snapshot of the database as it looked when you initiated the dump
| improve this answer | |
-1

Jehad Keriaki nailed it. For InnoDB Engine Hot Backup, Percona is having a backup solution called "XtraBackup" which I believe is based on

| improve this answer | |
  • I didn't ask for mysqldump alternatives, I asked a specific question about mysqldump – knocte Jun 28 '16 at 2:09
  • @knocte even if you asked that, you can't forbid answers of the kind "No, X is not hot, but Y is hot". This answer could use a bit more info (like a link to XtraBackup) but it can be useful for people with similar questions. – ypercubeᵀᴹ Jun 29 '16 at 7:22
  • I didn't downvote – knocte Jun 29 '16 at 7:23

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.