CentosDebianFedoraLinuxMySqlUbuntu

Create Mysql Backup Using Mylvmbackup On CentOS

mylvmbackup is a tool for quickly creating backups of a MySQL server’s data files. To perform a backup, mylvmbackup obtains a read lock on all tables and flushes all server caches to disk, creates a snapshot of the volume containing the MySQL data directory, and unlocks the tables again. The snapshot process takes only a small amount of time. When it is done, the server can continue normal operations, while the actual file backup proceeds.

The LVM snapshot is mounted to a temporary directory and all data is backed up using the tar program. By default, the archive file is created using a name of the form backup-YYYYMMDD_hhmmss_mysql.tar.gz, where YYYY, MM, DD, hh, mm, and ss represent the year, month, day, hour, minute, and second of the time at which the backup occurred. The default prefix backup, date format and file suffix can be modified. The use of timestamped archive names allows you to run mylvmbackup many times without danger of overwriting old archives.

Install the prerequisites

First enable rpmforge repo

# yum install make perl perl-Config-IniFiles perl-TimeDate perl-DBD-MySQL

Download the latest version of mylvmbackup, untar it and run make

wget http://www.lenzg.net/mylvmbackup/mylvmbackup-0.13.tar.gz
tar zxvf mylvmbackup-0.13.tar.gz
cd mylvmbackup-0.13
make install
which mylvmbackup

Now mylvmbackup assumes that your mysql data dir is on a lvm, since its essentially a perl script taking lvm snapshot of the directory. Also make sure sure you have enough space available on the volume group for mylvmbackup to use during the snapshot. Sample from my machine in the screenshot below.
To run backup execute mylvmbackup as shown below. Replace the password, path of my.cnf, vgname, lvname, backuptype and backupdir according to your environment.

mylvmbackup --user=root --password=admin@123 --innodb_recover --skip_flush_tables --mycnf=/etc/my.cnf --vgname=mysqldata --lvname=mysql01 --backuptype=rsync --backupdir=/opt

You can now access your backup under /opt directory as shown in the screenshot.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

CAPTCHA


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

Check Also
Close
Back to top button