Quick Start Example: Difference between revisions
(17 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
This section shows a simple example configuration of the Zmanda Recovery Manager (ZRM) for MySQL to perform backup, recovery and reporting. | |||
The example backs up all databases in a MySQL server that has ZRM for MySQL installed locally to that server. | |||
===Assumptions=== | ===Assumptions=== | ||
* | * ZRM for MySQL has been installed on the MySQL server. | ||
* MySQL database has been installed from rpms provided by [http://dev.mysql.com/downloads/mysql/5.0.html MySQL]. | * The '''/var/lib/mysql-zrm''' directory has sufficient space to hold all backup images for all the MySQL databases on the server. | ||
* MySQL database server (mysqld) has been started and is running on the server using default port (3306) | * The MySQL database has been installed from rpms provided by [http://dev.mysql.com/downloads/mysql/5.0.html MySQL]. This example assumes MySQL version 5.0. | ||
* MySQL application that uses the database has been configured on the server. | * The MySQL database server daemon ('''mysqld''') has been started and is running on the server using the default TCP port (3306) | ||
* MySQL database | * The MySQL application that uses the database has been configured on the server. | ||
* The MySQL database user account '''mysqlbackup''' is entered in the MySQL '''my.cnf''' option file. The option file is located in '''$MYSQL_HOME/my.cnf'''. Please follow instructions provided in [http://dev.mysql.com/doc/refman/4.1/en/password-security.html MySQL manual] on how to secure database user passwords in a MySQL options file. For example: | |||
[client] | [client] | ||
Line 15: | Line 16: | ||
password="mysqlbackup_password" | password="mysqlbackup_password" | ||
* Consult [http://dev.mysql.com/doc/refman/5.0/en/option-files.html MySQL reference manual] for more information on MySQL option files. | * Consult the [http://dev.mysql.com/doc/refman/5.0/en/option-files.html MySQL reference manual] for more information on MySQL option files. | ||
* Consult MySQL backup user section | * Consult the [http://mysqlbackup.zmanda.com/index.php/Do_I_need_to_make_changes_to_MySQL_database_configuration%3F#MySQL_backup_user MySQL backup user] section for details on configuring a MySQL user '''mysqlbackup'''. | ||
Note that all ZRM for MySQL commands must be run as the '''mysql''' operating system user. | |||
* MySQL client commands are installed in ''/usr/bin/'' directory. If they are not, accordingly configure the client command location and binary log location in [[mysql-zrm.conf]]. See [[Backup_Set_Parameters#MySQL_Server_Parameters|MySQL server parameters section]] for details. | |||
==== Performing Incremental Backups ==== | |||
By default, all MySQL databases accessible to the MySQL server are configured for full backup. To perform incremental backup instead, restart the MySQL server daemon ('''mysqld''') with binary logs enabled. To enable binary logs, add the '''--log-bin''' option to '''mysqld''' where it is invoked in the '''/etc/init.d/mysqld''' script. | |||
Consult [[Backup_Sets|Backup Sets]] section for more details. | Consult the [http://mysqlbackup.zmanda.com/index.php/Do_I_need_to_make_changes_to_MySQL_database_configuration%3F#Binary_logs|MySQL binary logs] section for details on configuring binary logs. | ||
Consult the [[Backup_Sets|Backup Sets]] section for more details. | |||
=== Schedule MySQL Database Backups === | === Schedule MySQL Database Backups === | ||
Line 36: | Line 35: | ||
The [[mysql-zrm-scheduler]] utility helps you to schedule automatic periodic backups of the databases. | The [[mysql-zrm-scheduler]] utility helps you to schedule automatic periodic backups of the databases. | ||
First, perform an immediate backup | |||
$ mysql-zrm-scheduler --now --backup-set dailyrun --backup-level 0 | $ mysql-zrm-scheduler --now --backup-set dailyrun --backup-level 0 | ||
Which creates a '''dailyrun''' backup set that backs up the databases to the '''/var/lib/mysql-zrm/dailyrun''' directory. | |||
Next schedule weekly full backups on Sunday at 2 AM: | Next, schedule weekly full backups on Sunday at 2 AM: | ||
$ mysql-zrm-scheduler --interval weekly --backup-set dailyrun --start 02:00 | $ mysql-zrm-scheduler --add --interval weekly --backup-set dailyrun --start 02:00 | ||
Consult the [[Daily/_Weekly/_Monthly_Schedules]] section for more complex backup scheduling. | Consult the [[Daily/_Weekly/_Monthly_Schedules]] section for more complex backup scheduling. | ||
Line 50: | Line 49: | ||
===Generate Backup Status Reports=== | ===Generate Backup Status Reports=== | ||
The [[mysql-zrm-reporter]] utility | The [[mysql-zrm-reporter]] utility lets you generate standard and customized reports to monitor backup runs. | ||
For example, this command generates a status report: | |||
$ mysql-zrm-reporter --where backup-set=dailyrun --show backup-status-info | $ mysql-zrm-reporter --where backup-set=dailyrun --show backup-status-info | ||
Line 59: | Line 58: | ||
dailyrun Sun 17 Sep 2006 02:16:43 AM PDT 0 Backup succeeded ---- | dailyrun Sun 17 Sep 2006 02:16:43 AM PDT 0 Backup succeeded ---- | ||
Consult | Consult the [[Backup_Reports|Backup reports section]] of ZRM for MySQL to generate more complex reports. | ||
===Restore MySQL Database=== | ===Restore the MySQL Database=== | ||
Restoration of backups is done in two steps: | Restoration of backups is done in two steps: | ||
'''Step 1:''' Identify the backup image to be restored. Run a backup report ('''restore-info''') to list all the backup images that are available: | |||
$ /usr/bin/mysql-zrm-reporter -show restore-info --where backup-set=dailyrun | $ /usr/bin/mysql-zrm-reporter -show restore-info --where backup-set=dailyrun | ||
Line 75: | Line 74: | ||
02:16:43 AM PDT 20060917021643 | 02:16:43 AM PDT 20060917021643 | ||
'''Step 2:''' Use the '''[[mysql-zrm]]''' utility to restore the database from the full backup image. | |||
$ mysql-zrm --action restore --backup-set dailyrun \ | $ mysql-zrm --action restore --backup-set dailyrun \ |
Latest revision as of 23:13, 30 January 2008
This section shows a simple example configuration of the Zmanda Recovery Manager (ZRM) for MySQL to perform backup, recovery and reporting. The example backs up all databases in a MySQL server that has ZRM for MySQL installed locally to that server.
Assumptions
- ZRM for MySQL has been installed on the MySQL server.
- The /var/lib/mysql-zrm directory has sufficient space to hold all backup images for all the MySQL databases on the server.
- The MySQL database has been installed from rpms provided by MySQL. This example assumes MySQL version 5.0.
- The MySQL database server daemon (mysqld) has been started and is running on the server using the default TCP port (3306)
- The MySQL application that uses the database has been configured on the server.
- The MySQL database user account mysqlbackup is entered in the MySQL my.cnf option file. The option file is located in $MYSQL_HOME/my.cnf. Please follow instructions provided in MySQL manual on how to secure database user passwords in a MySQL options file. For example:
[client] # The following password will be sent to all standard MySQL clients user=mysqlbackup password="mysqlbackup_password"
- Consult the MySQL reference manual for more information on MySQL option files.
- Consult the MySQL backup user section for details on configuring a MySQL user mysqlbackup.
Note that all ZRM for MySQL commands must be run as the mysql operating system user.
- MySQL client commands are installed in /usr/bin/ directory. If they are not, accordingly configure the client command location and binary log location in mysql-zrm.conf. See MySQL server parameters section for details.
Performing Incremental Backups
By default, all MySQL databases accessible to the MySQL server are configured for full backup. To perform incremental backup instead, restart the MySQL server daemon (mysqld) with binary logs enabled. To enable binary logs, add the --log-bin option to mysqld where it is invoked in the /etc/init.d/mysqld script.
Consult the binary logs section for details on configuring binary logs.
Consult the Backup Sets section for more details.
Schedule MySQL Database Backups
The mysql-zrm-scheduler utility helps you to schedule automatic periodic backups of the databases.
First, perform an immediate backup
$ mysql-zrm-scheduler --now --backup-set dailyrun --backup-level 0
Which creates a dailyrun backup set that backs up the databases to the /var/lib/mysql-zrm/dailyrun directory.
Next, schedule weekly full backups on Sunday at 2 AM:
$ mysql-zrm-scheduler --add --interval weekly --backup-set dailyrun --start 02:00
Consult the Daily/_Weekly/_Monthly_Schedules section for more complex backup scheduling.
Generate Backup Status Reports
The mysql-zrm-reporter utility lets you generate standard and customized reports to monitor backup runs. For example, this command generates a status report:
$ 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 ----
Consult the Backup reports section of ZRM for MySQL to generate more complex reports.
Restore the MySQL Database
Restoration of backups is done in two steps:
Step 1: Identify the backup image to be restored. Run a backup report (restore-info) to list all the 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
Step 2: Use the mysql-zrm utility to restore the database from the 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.
Consult the restoration section for more details on MySQL database recovery.