Quick Start Example: Difference between revisions

From wiki.zmanda.com
Jump to navigation Jump to search
No edit summary
 
m (minor grammatical corrections)
Line 1: Line 1:
Configure  ''ZRM for MySQL''  for a simple MySQL server configuration and do backup, recovery and reporting.
Configure  ''ZRM for MySQL''  for a simple MySQL server configuration and do backup, recovery and reporting.
This example backups all databases in a MySQL server using ''ZRM for MySQL'' running on the same machine.
This example backs up all databases in a MySQL server using ''ZRM for MySQL'' running on the same machine.


===Assumptions===
===Assumptions===
Line 23: Line 23:
=== Configure ''ZRM for MySQL'' ===
=== Configure ''ZRM for MySQL'' ===


No configuration of  ''ZRM for MySQL'' is 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 a part of the backup set.
No configuration of  ''ZRM for MySQL'' is required to do full raw backups of all databases in the MySQL server. By default, all MySQL databases that are accessible to the MySQL server are backed up as a part of the backup set.


'''For incremental backups:'''
'''For incremental backups:'''


* Restart to the MySQL server (''mysqld'') with binary logs enabled.
* Restart the MySQL server (''mysqld'') with binary logs enabled.
* Add ''--log-bin'' option to mysqld in /etc/init.d/mysqld script.
* Add ''--log-bin'' option to mysqld in /etc/init.d/mysqld script.
* Consult [http://mysqlbackup.zmanda.com/index.php/Do_I_need_to_make_changes_to_MySQL_database_configuration%3F#Binary_logs|MySQL binary logs] section for configuring binary logs.
* Consult [http://mysqlbackup.zmanda.com/index.php/Do_I_need_to_make_changes_to_MySQL_database_configuration%3F#Binary_logs|MySQL binary logs] section for configuring binary logs.
Line 35: Line 35:
=== Schedule MySQL Database Backups ===
=== Schedule MySQL Database Backups ===


The [[mysql-zrm-scheduler]] utility helps you to schedule automatic periodical backups of the databases.
The [[mysql-zrm-scheduler]] utility helps you to schedule automatic periodic backups of the databases.


Start by doing an immediate backup
Start by doing an immediate backup
Line 41: Line 41:
  # mysql-zrm-scheduler --now --backup-set dailyrun --backup-level 0
  # 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/dailyrun directory.
A backup set dailyrun is created and backups are done 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 --interval weekly --backup-set dailyrun --start 02:00
Line 76: Line 76:
                 02:16:43 AM PDT                        20060917021643
                 02:16:43 AM PDT                        20060917021643


; Step 2 : Use [[mysql-zrm]] utility to restore the database from the full backup image.
; 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 \

Revision as of 20:48, 11 December 2007

Configure ZRM for MySQL for a simple MySQL server configuration and do backup, recovery and reporting. This example backs up all databases in a MySQL server using ZRM for MySQL 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 that will be used for backup and restore has been 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"
  • Consult MySQL reference manual for more information on MySQL option files.
  • Use of MySQL root user for backup/restore is not recommended.
  • Consult MySQL backup user section on how to configure a different backup user.
  • ZRM for MySQL is installed on the server.
  • All ZRM for MySQL commands have to be run as OS superuser ("root").

Configure ZRM for MySQL

No configuration of ZRM for MySQL is required to do full raw backups of all databases in the MySQL server. By default, all MySQL databases that are accessible to the MySQL server are backed up as a part of the backup set.

For incremental backups:

  • Restart the MySQL server (mysqld) with binary logs enabled.
  • Add --log-bin option to mysqld in /etc/init.d/mysqld script.
  • Consult binary logs section for configuring binary logs.

Consult 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.

Start by doing an immediate backup

# mysql-zrm-scheduler --now --backup-set dailyrun --backup-level 0

A backup set dailyrun is created and backups are done to the /var/lib/mysql-zrm/dailyrun directory.

Next schedule weekly full backups on Sunday at 2 AM:

# mysql-zrm-scheduler --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 generates many predefined and user defined reports on backup runs. Use it to generate status report as under:

  #  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 Backup reports section of ZRM for MySQL for more complex reports.

Restore MySQL Database

Restoration of backups is done in two steps:

Step 1
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
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.