mylvmbackup
works by using the following procedure:
FLUSH TABLES
: ForcesMyISAM
buffers to disk as far as possible, but it does not lock the tables.FLUSH TABLES WITH READ LOCK
: ForcesMyISAM
buffers to disk that have been dirtied since the lastFLUSH TABLES
command. This time, all queries modifying the databases are locked.lvcreate -s
: This creates a consistent snapshot.UNLOCK TABLES
: This writes to the database resume.Mount the snapshot to a temporary directory.
tar
and compress the snapshot. If configured (not covered in this appendix),rsync
this file to another location.Destroy the snapshot.
Be aware that when holding an open snapshot, the "copy on write" architecture of LVM can cause significant performance degradation—one I/O operation without a snapshot may take three to six I/O operations, when there is an open snapshot.
If you only use InnoDB
tables and the additional activity at block-device level during snapshots causes problems, you can consider the open source Xtrabackup
project (https://launchpad.net/percona-xtrabackup), which aims to achieve zero downtime backups at application level and without this overhead. However, for a database server with cyclical load, it is often possible to schedule backups at a low time where additional I/O will not cause problems.