Is mysqldump a "hot" backup kind?
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
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.