MySQL Extension

The MySQL Extension is a Cedar Backup extension used to back up MySQL [32] databases via the Cedar Backup command line. It is intended to be run either immediately before or immediately after the standard collect action.

The backup is done via the mysqldump command included with the MySQL product. Output can be compressed using either gzip or bzip2. Administrators can configure the extension either to back up all databases or to back up only specific databases. The extension assumes that all databases can be backed up by a single user (typically root).

Note that this code always produces a full backup. There is currently no facility for making incremental backups. If/when someone has a need for this and can describe how to do it correctly, I'll update this extension or provide another.

Unfortunately, use of this extension will expose usernames and passwords in the process listing (via ps) when the backup is running. This is because none of the official MySQL backup scripts provide a good way to specify password other than via the --password command-line option. The only workaround I can come up with would be to manipulate program I/O interactively through a pipe, which is a real pain.

To enable this extension, add the following section to the Cedar Backup configuration file:

<extensions>
   <action>
      <name>mysql</name>
      <module>CedarBackup2.extend.mysql</module>
      <function>executeAction</function>
      <index>101</index>
   </action>
</extensions>
      

This extension relies on the options and collect configuration sections in the standard Cedar Backup configuration file, and then also requires its own mysql configuration section. This is an example MySQL configuration section:

<mysql>
   <user>root</user>
   <password>password</password>
   <compress_mode>bzip2</compress_mode>
   <all>Y</all>
</mysql>
      

You should always make /etc/cback.conf unreadable to non-root users once you place MySQL configuration into it, since it contains information about available MySQL databases, usernames and passwords.

The following elements are part of the MySQL configuration section:

user

Database user.

The database user that the backup should be executed as. Even if you list more than one database (below) all backups must be done as the same user. Typically, this would be root (i.e. the database root user, not the system root user).

Restrictions: Must be non-empty.

password

Password associated with the database user.

Note that once you put this value into configuration, you should make sure that your configuration file cannot be read by users which should not see this password.

Restrictions: Must be non-empty.

compress_mode

Compress mode.

MySQL databases dumps are just specially-formatted text files, and often compress quite well using gzip or bzip2. The compress mode describes how the backed-up data will be compressed, if at all.

Restrictions: Must be one of none, gzip or bzip2.

all

Indicates whether to back up all databases.

If this value is Y, then all MySQL databases will be backed up. If this value is N, then one or more specific databases must be specified (see below).

If you choose this option, the entire database backup will go into one big dump file.

Restrictions: Must be a boolean (Y or N).

database

Named database to be backed up.

If you choose to specify individual databases rather than all databases, then each database will be backed up into its own dump file.

This field can be repeated as many times as is necessary. At least one database must be configured if the all option (above) is set to N. You may not configure any individual databases if the all option is set to Y.

Restrictions: Must be non-empty.