Quick start example
In this section, we configure MySQL ZRM for doing backup, recovery and reporting for a simple MySQL server configuration.
This illustration backups all databases in a MySQL server using MySQL ZRM running on the same machine.
Assumptions
- The /var/lib/mysql-zrm directory has sufficient space to contain all backup images for all the MySQL databases on the server.
- MySQL database has been installed from rpms provided by MySQL.
- MySQL database server (mysqld) has been started and is running on the server using default port (3306)
- MySQL application that uses the database has been configured on the server.
- MySQL database root user will be used for backups and restores. It must be configured in my.cnf options file. The options file is located in /etc/my.cnf (global) or $MYSQL_HOME/my.conf (server specific) For example:
[client] # The following password will be sent to all standard MySQL clients user=root password="my_password"
- For more information on MySQL option files, see MySQL reference manual. Use of MySQL root user for backup/restore is not recommended. See MySQL backup user section for more information on how to configure a different backup user.
- MySQL ZRM is installed on the server.
- All MySQL ZRM commands has to be run as Linux superuser ("root").
MySQL ZRM configuration
There is no MySQL ZRM configuration required to do full raw backups of all databases in the MySQL server. By default, all MySQL databases that are accessible to MySQL server are backed up as part of default backup set.
To do incremental backups, it is necessary to restart to the MySQL server (mysqld) with binary logs enabled. Add --log-bin option to mysqld in /etc/init.d/mysqld script. For further information on configuring binary logs, please see MySQL binary logs section.
For more information on MySQL ZRM configuration, see "How do I configure MySQL ZRM?" section.
MySQL database backups
To do a backup of all databases now, use mysql-zrm-scheduler tool.
# mysql-zrm-scheduler --now --backup-set dailyrun --backup-level 0
A backup set dailyrun is created and backups are done to /var/lib/mysql-zrm directory.
To schedule weekly full backups on Sunday at 2am:
# mysql-zrm-scheduler --interval weekly --backup-set dailyrun --start 02:00
For more information on backup scheduling, see MySQL ZRM backup section.
Backup reports
mysql-zrm-reporter tool can obtain the status of backup run as well as produce various reports on the backup runs.
# mysql-zrm-reporter --where backup-set=dailyrun --show backup-status-info backup_set backup_date backup_level backup_status comment ---------------------------------------------------------------------------------------------------- dailyrun Sun 10 Sep 2006 02:15:23 AM PDT 0 Backup succeeded ---- dailyrun Sun 17 Sep 2006 02:16:43 AM PDT 0 Backup succeeded ----
For more information on MySQL ZRM backup reporting, please see Backup reports section.
MySQL database restoration
Restoration of backups requires two steps:
- Identify the backup image to be restored. Run a backup report (restore-full-info) to find out all backup images that are available:
# /usr/bin/mysql-zrm-reporter -show restore-info --where backup-set=dailyrun backup_set backup_date backup_level backup_directory ------------------------------------------------------------------------------------------- dailyrun Sun 10 Sep 2006 0 /var/lib/mysql-zrm/dailyrun/ 02:15:23 AM PDT 20060910021523 dailyrun Sun 17 Aug 2006 0 /var/lib/mysql-zrm/dailyrun/ 02:16:43 AM PDT 20060917021643
- Use mysql-zrm tool to restore the database from a full backup image.
# mysql-zrm --action restore --backup-set dailyrun \ --source-directory /var/lib/mysql-zrm/dailyrun/20060917021643 MySQL server has been shutdown. Please restart after verification.
For more information on MySQL database recovery, please see MySQL database restoration section.