MySQL Backup of an ePages Installation 6.13.1
Created: 6.10.1; Updated: 6.10.1

Table of Contents

1 Basic backup methods

Raw backup
Copying of the various database files on hard disc level to a backup device.
Logical backup
Exporting the data on the database level using database internal statements. Data will be extracted and written to the backup device.
Hot backup
Backup of the running database. The database doesn't need to be shut down.
Cold backup
Database has to be shut down for the backup.

2 Backup in ePages 6.10.0 and higher

ePages 6.10.0 uses MySQL 5.0 / 5.1 databases and provides three backup types:

The scripts to start the backups are located in:

  $EPAGES_CARTRIDGES/DE_EPAGES/Database/Scripts

Running the scripts with parameter -help displays an explanation of all parameters.

The backup files will be stored by default in $EPAGES/MySQLDumps.

Another location can be defined via:

  Dumpdir= /srv/dumps

  perl MySQLBackup.pl -full -storename Store -dumpdir /srv/dumps

3 MySQLBackup / MySQLRestore

This backup method is based on the default MySQL tool 'mysqldump' which comes with the MySQL installation.

It is a logical backup. Because of the parameters applied, the script performs a hot backup.

3.1 Full backup

  perl MySQLBackup.pl -full -storename Store -dumpdir /srv/dumps

Using the parameter -storename allows backup of a special Store database. If the parameter is missing, all databases are stored in the backup file.

The backup is stored in a *.dmp file in the given dumpdir.

3.2 Restoring a full backup

The database system has to be running to perform the restore. It's recommended to shut down the epages application to avoid data inconsistencies during the restore.

  perl MySQLRestore.pl -dumpdir /srv/dumps -storename Store

3.3 Incremental backups

You can also perform incremental backups. Incremental backups use the BinLog functionality of MySQL.

Prerequisite is the 'log_bin' entry in the MySQL config file (e.g. my.cnf) in the section [mysqld]:

  [mysqld]
  log_bin = mysql-bin

'mysql-bin' is the relative or absolute path name where the backup files are stored. If the value is not defined the data is stored in a directory using the host name in the data directory of the MYSQL installation. This naming is inflexible and therefore not recommended.

The incremental backup stores the data localy - make sure that enough disc space is available.

Perform the incremental backup using the -log parameter instead of -full, like the following example:

  perl MySQLBackup.pl -log -storename Store -dumpdir /srv/dumps

The backup files are stored as binary files. They can be converted into a readable format using the MySQL tool 'mysqlbinlog':

  mysqlbinlog /srv/dumps/mysql-bin.000161 /srv/dumps/mysql-bin.000162 [...]

The converted file contains event numbers. These event numbers can be used as restore points.

To restore data based on an incremental backup, use a command like the following example:

  perl MySQLRestore.pl -storename Store -dumpdir /srv/dumps -lastfile mysql-bin.000162 -lastpos 184

The value of the parameter '-lastpos' is an event number of the relevant converted backup file.

For more information, see http://www.mysql.com http://dev.mysql.com/doc/refman/5.1/en/binary-log.html .

4 MySQLHotBackup / MySQLHotRestore

This backup method uses the commercial tool 'InnoDB HotBackup'. You have to buy the tool to get a binary file. This file has to be specified later in the backup command via the parameter '-ibbackup'. The backup is a hot raw backup.

Prerequisite to perform the backup is adding some entries in the MySQL config file (e.g. my.cnf) in the section [mysqld]:

  innodb_data_home_dir = /var/lib/mysql
  # Path of data directory

  innodb_data_file_path = ibdata1:10M:autoextend
  # Size of the InnoDB data file (Default setting)

  innodb_log_group_home_dir = /var/lib/mysql
  # Path of log files (Default setting)

  innodb_log_files_in_group = 2
  # Number of log files (Default setting)

  innodb_log_file_size = 5M
  # Size of log files (Default setting)

In case of a default installation, the values don't need to be changed. Usually, only the value for 'innodb_data_home_dir' has to be adapted.

Perform the backup using a command like the following example:

  perl MySQLHotBackup.pl -full -dumpdir /srv/dumps -ibbackup /usr/bin/ibbackup

The incremental backup can be performed similar to that of the MySQLBackup. The restore is similar, too:

  perl MySQLHotRestore.pl -storename Store -dumpdir /srv/dumps -lastfile mysql-bin.000161 -lastpos 184

For more information, see http://www.innodb.com/ and http://www.innodb.com/doc/hot_backup/manual.html .

5 MySQLLVMBackup / MySQLLVMRestore

The LVM-backup can be performed on linux systems where the MySQl data directory is located on av LVM volume. The backup is a hot raw backup.

The script processes all tasks of the LVM-backup (mounting partitions, copying files, creating snapshots etc.). Therefore, some additional parameters are necessary in the command line:

  perl MySQLLVMBackup.pl -full -dumpdir /srv/dumps -snapshotsize 30G -lvmgroup mysql -lvmdata data

-snapshotsize
The value specified should cover ca.10-20 % of the data.
-lvmgroup
Destination partition for the snapshot
-lvmdata
Locical partition name
For the restore, the restore path has to be specified:

  perl MySQLLVMRestore.pl -dumpdir /srv/dumps -restorepath  /var/lib/mysql

For more information see http://www.linuxhaven.de/dlhp/HOWTO/DE-LVM-HOWTO-3.html and http://tldp.org/HOWTO/LVM-HOWTO/ .

6 Scheduler

The backups can be performed via the scheduler. The relevant sections for MySQL backups are prepared in $EPAGES_CONFIG/Scheduler.conf of epages 6.10.0 and higher.

Usual options are -fullbackup, -logbackup, or -nooutput. The -nooutput option suppresses additional output into the log file.

By default, all stores are are backed up, but restriction of to single Store is possible.

The default backup method is MySQLBackup. You can change the backup method in the relevant $EPAGES_CONFIG/Database.d/[Storedb].conf. You have to define the parameter 'BackupVariant' then:

  BackupVariant =        # MySQLBackup
  BackupVariant = Hot    # MySQLHotBackup
  BackupVariant = LVM    # MySQLLVMBackup

Additional options can be added via 'BackupMySQLArgs'.

Example for setting up a HotBackup:

  BackupVariant=Hot
  BackupMySQLArgs=-ibbackup $EPAGES_CARTRIDGES/DE_EPAGES/Database/Scripts/ibbackup

7 Performance issues

MySQLBackup
The duration of the restore doesn't increase linearly with data volume. If the amount of data is double-digit or three-digit, the restore may take several hours, while the backup may take significantly less time. MySQL recommends using one of the other methods, or to perform a cold raw backup if the data volume is very high.
MySQLHotBackup
The restore and backup time increases linearly depending on the data volume. The database will be shut down during the restore process because the data directory has to be swapped.
MySQLLVMBackup
Using MySQLLVMBackup, a snapshot of the data partition can be created within seconds. The data is saved in parallel to the running process. The time of the whole backup process isn't significantly shorter than with the other methods, but the database itself is loaded for just a short time. The restore time equals that of MySQLHotBackup because of the file copy procedure.

Copyright ePages Software GmbH 2012