MySQL Backup of an ePages Installation | → 6.13.1 | Created: 6.10.1; Updated: 6.10.1 |
Table of Contents |
ePages 6.10.0 uses MySQL 5.0 / 5.1 databases and provides three backup types:
$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
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.
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.
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
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 .
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 .
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
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/ .
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