Languages

Login

Search form

You are here

FromDual Backup and Recovery Manager (brman) User Guide

Tue, 2014-05-06 17:28 — Shinguz

About

The FromDual Backup and Recovery Manager for MariaDB and MySQL (brman) is an application to ease the use of the various MariaDB/MySQL backup tools. The Problem with MariaDB/MySQL backup tools is, that they have many options and thus are over-complicated and errors are easy made.

bman has the intention to make backups for MariaDB/MySQL easier and technically correct. This means it should per default not allow non-consistent backups or complain if some functions or parameters are used in the wrong way to guarantee proper backups.

In addition it has added some nice features which are missing in standard MariaDB/MySQL backup tools or which are only known from Enterprise backup solutions.

Where to download brman

The FromDual Backup and Recovery Manager for MariaDB and MySQL (brman) can be downloaded from our website.

With this backup method we do a logical full backup (mysqldump is triggered in the background). The backup is stored in the location for backups with the daily policy and is NOT compressed to speed up the backup by saving CPU power AND because the backup device is a de-duplicating drive. Then the backup is archived to and NFS mount.

Backup types

To achieve this we have defined different backup types:

Type

Description

full

Do a full logical or physical backup (mysqldump/mysqlbackup/mariabackup/xtrabackup) of all schemas.

binlog

Do a binary log backup.

config

Do configuration file backup (my.cnf).

structure

Do a structure backup (no data).

cleanup

Do a clean-up of backups older than n days.

schema

Do backup of one or more schemas (together or separated).

privilege

Do a privilege backup (SHOW GRANTS FOR).

A backup type is specified with the option --type=<backup_type>.

Backup modes

A backup can either be logical or physical. A logical backup is typically what you do with mysqldump. A physical backup is typically a physical file copy without looking into the data. That is what for example mariabackup does.

The backup mode is specified with the option --mode=<backup_mode>. The following backup modes are available:

Mode

Description

logical

Do a logical backup (mysqldump).

physical

Do a physical backup (mysqlbackup/mariabackup/xtrabackup).

Backup policies

Further we have introduced different backup policies. Policies are there to distinguish how different backups should be treated.

The following backup policies exist:

Policy

Description

daily

Directory to store daily backups.

weekly

Directory to store weekly backups.

monthly

Directory to store monthly backups.

quarterly

Directory to store quarterly backups.

yearly

Directory to store yearly backups.

binlog

Directory to store binary log backups.

For example you could plan to do a daily MariaDB/MySQL backup with binary logs with a retention policy of 7 days. But once a week you want to do a weekly backup consisting of a full backup, a configuration backup and a structure dump. But this weekly backup you want to keep for 6 months. And because of legal reasons you want to do a yearly backup with a retention policy of 10 years.

A backup policy is specified with the --policy=<backup_policy> option. This leads us to the retention time:

Options

The retention time which should be applied to a specific backup policy you can specify with the option --retention=<period_in_days>. The retention option means that a backup is not deleted before this amount of days when you run a clean-up job with bman.

Let us do an example:

shell> bman --type=cleanup --policy=daily --retention=30

This means that all backups in the daily policy should be deleted when they are older than 30 days.

Target

With the --target option you specify the connect string to the database to backup. This database can be located either local (all backup types can be used) or remote (only client/server backup types can be used (mysqldump)).

A target looks as follows: user:password@host:port (similar to URI specification) whereas you can omit password and port.

Backup location, archiving, compressing and clean-up

The --backupdir option is to control location of the backup files. The policy folders are automatically created under this --backupdir location.
If you have a second layer of backup stores (e.g. tapes or slow backup drives or deduplicated drives or NFS drives) you can use the --archive option to copy your backup files to this second layer storage which is specified with the --archivedestination option. For restore performance reasons it is recommended to always keep one or two generations of backups on your fast local drive. If you want to remove the backuped files from the --backupdir destination after the archive job use the --cleanup option.
If you want to omit to compress backups, either to safe time or because your location uses deduplicated drives you can use the --no-compress option.

Per schema backup

Especially for shared hosting companies (or multi tenant applications) a full database backup is typically not the right backup strategy because a restore of one specific customer (= schema) is very complicated. For this case we have the --per-schema option. bman will do a backup of the whole database schema by schema. Keep in mind: This breaks consistency among schemas!

Sometimes you want to do a schema backup only for some specific schemas for this you can use the --schema option. This option allows you to specify schemas to backup or not to backup. --schema=+a,+b means backup schema a and b. --schema=-a,-b means backup all schemas except a and b.
The second variant is less error prone because you do not forget to backup a new schema.

Instance name

MariaDB/MySQL does not know the concept of naming an instance (mysqld). But for bigger environments it could be useful to uniquely name each instance. For this purpose we have introduced the option --instance-name=<give_it_a_name>. This instance name should be unique within your whole company. But we do not enforce it atm. The instance name is used to name backup files and later to identify the backup history of an instance in our backup catalog and to allow us to track the files for restore.

bman configuration file

Specifying everything on the command line is cumbersome. Thus bman considers a configuration file specified with the --config=<config_file> option.
A bman configuration file looks for example as follows:

Simulate what happens

For the Sissies among us (as for example me) we have the --simulate option. This option simulates nearly all steps as far as possible without executing really anything. This option is either for testing some features or for debugging purposes.

Logging

If you want to track your backup history you can specify with the --log option where your bman log file should be located.

Using Catalog

It will be very useful when you can store your backups metadata in the database so you can check them in the future and to find out the backup criteria (type, mode, instance-name, ... etc) for specific backup processes. This could be achieved by using the catalog feature.

To activate this feature you have to create a schema for the catalog "default name is brman_catalog" then create its tables by using the option --create in a special bman command (check examples below).
Finally, to store your backup metadata in the catalog what you only have to do is adding the option --catalog=catalog_connection_string to the normal bman command.
Check the examples below for using catalog in bman.

Examples

To just see if bman works correctly just run:

shell> bman --version

To get a compact help of what bman can do run the following command. This output is the most reliable and most up-to-date source of information about brman (documentation may not be up-to-date):

shell> bman --help

Do a full (logical = default) backup and store it in the daily policy folder:

Examples with other options

If you want to pass through options to the underlying backup utility (mysqldump, mariabackup, xtrabackup, mysqlbackup) you can use the --pass-through option. In the following example the mysqldump utility omits dumping the CountryLanguage table in a world schema backup:

If you are using the FromDual Performance Monitor for MariaDB and MySQL (fpmmm) and/or Zabbix for database monitoring you can send the backup information also to your monitoring solution for getting trends and see errors or anomalies:

Tools

Navigation

Trademarks

RSSLinkedInTwitterXingFacebookFlickrGoogle+Follow @fromdual
MySQL, InnoDB and Oracle are registered trademarks of Oracle Corp. MariaDB is a trademark of Monty Program AB.
All other trademarks are property of their respective owners. Other product or company names mentioned may be trademarks or trade names of their respective owner.