Skip to end of metadata
Go to start of metadata

Is It Safe To Backup MySQL Without Lock And Flush?

Question:

Is it safe to backup MySQL without Lock and Flush?

Solution:

It can be done, but we do not recommend it.

Lock and Flush is done by the MySQL Agent add-on.

If you backup MySQL without locking tables and flushing in memory open tables, then you are likely to get corruption if the database is being updated or changed when you backup.

MySQL is very good at recovering from unclean shutdowns. On startup it will detect that its an unclean shutdown when you recover from an unclean backup and automatically repair your corrupt MyISAM tables.

Without the MySQL Add-on, you will loose whatever changes were being made to the database at the time of the backup.

Note that the R1Soft MySQL backup process is different from a normal hot backup.

MySQL Hot Backup Process (mysqlhotcopy)

  1. Lock all tables.
  2. Flush all table changes to disk.
  3. Copy all raw database files (could take a long time).
  4. Unlock tables.

R1Soft MySQL Hot Backup Process

  1. Lock all tables.
  2. Flush all table changes to disk.
  3. Snapshot the raw partition using the r1soft near-CDP device driver /dev/backupdriver.
    Note: This takes less than a second.
  4. Unlock tables.
  5. If seed copy: All raw MySQL files from point-in-time snapshot of volume/partition.
    If not a seed copy: Only changed blocks from point-in-time snapshot of volume/partition.

Note this step can take a long time if you are doing a seed or have a lot of changes to your database like importing a large amount of data. This is fine since we are not holding table locks anymore. Also, you get the benefits of a totally consistent copy of MySQL raw table files by reading from the block level point-in-time copy-on-write snapshot that is maintained by /dev/backupdriver.

This is significant because your application and queries can continue while the backup is taking place (step 5).

With typical hot backup queries, they will timeout, web pages will fail to load, and systems will be down for the duration of the backup operation.

If you are backing up MySQL in a hotbackup fashion and are not locking and flushing tables, you could experience serious data loss.

Related Articles


Page: Agent shows a MySQL Error in the logs about MYHELPER (Archived Knowledge Base 2.0) Labels: mysql, install, cdp_server
Page: MySql Restore Fails With Internal Error db.frm Not Found (Archived Knowledge Base 2.0) Labels: mysql, 2-11-release
Page: An IO Error Occurred While Parsing MySQL XML Document (Archived Knowledge Base 2.0) Labels: mysql, xml
Page: MySQL Agent Errors - dots in table filenames (Archived Knowledge Base 2.0) Labels: mysql
Page: License Upgrade Question (Archived Knowledge Base 2.0) Labels: upgrade, license, add-on, mysql
Page: Configuring MySQL instances running inside Virtuozzo VPS (Archived Knowledge Base 2.0) Labels: mysql, add-on, vps, buagent, h/w, node
Page: Restoring MySQL Fails (Archived Knowledge Base 2.0) Labels: mysql
Page: Failed to Start Database r1backup (Archived Knowledge Base 2.0) Labels: mysql
Page: How Do I Add a New MySQL Instance? (Archived Knowledge Base 2.0) Labels: mysql
Page: MySQL Add-on Locks Up MySQL or Backup Hangs During MySQL (Archived Knowledge Base 2.0) Labels: mysql
Page: MySQL Addon - Why MySQL Backups are Not Safe Without It (Archived Knowledge Base 2.0) Labels: mysql
Page: I Have CDP Server Installed - Can I Order MySQL Agent Add-On? (Archived Knowledge Base 2.0) Labels: mysql, license
Page: Enabling MySQL Add-On (Archived Knowledge Base 2.0) Labels: mysql, license
Page: Not having UTF8 set on older mysql servers no longer stops the backup (Archived Knowledge Base 2.0) Labels: mysql
Page: If MySQL backup fails, task state is set to error (Archived Knowledge Base 2.0) Labels: mysql
Page: Added support for innodb_file_per_table (Archived Knowledge Base 2.0) Labels: mysql
Page: Adding MySql Addon for Virtuozzo MySql Instance (Archived Knowledge Base 2.0) Labels: mysql, virtuozzo
Page: Do I Need Root Password of MySQL Database? (Archived Knowledge Base 2.0) Labels: mysql
Page: Is It Safe To Backup MySQL Without Lock And Flush? (Archived Knowledge Base 2.0) Labels: mysql
Page: Can I Restore MySQL Without Having MySQL Agent Add-on Installed? (Archived Knowledge Base 2.0) Labels: mysql
Page: MySQL - Fix permission errors seen in some environments during InnoDB restore (Archived Knowledge Base 2.0) Labels: mysql
Page: MySQL - Fix timeout error during large InnoDB restore (Archived Knowledge Base 2.0) Labels: mysql
Page: MySQL Backup (Archived Knowledge Base 2.0) Labels: mysql
Page: Recovering a Running MySQL Server (Archived Knowledge Base 2.0) Labels: mysql, restore
Page: MySQL Backup Error In Logs (Archived Knowledge Base 2.0) Labels: mysql, backup_error
Showing first 25 of 27 results
Labels:
mysql mysql Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.