Home | Trees | Index | Help |
|
---|
Package CedarBackup2 :: Package extend :: Module mysql |
|
Provides an extension to back up MySQL databases.
This is a Cedar Backup extension used to back up MySQL databases via the Cedar Backup command line. It requires a new configuration section <mysql> and is intended to be run either immediately before or immediately after the standard collect action. Aside from its own configuration, it requires the options and collect configuration sections in the standard Cedar Backup configuration file.
The backup is done via the mysqldump
command included
with the MySQL product. Output can be compressed using gzip
or bzip2
. Administrators can configure the extension either
to back up all databases or to back up only specific databases. 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, I'll update this extension or provide
another.
The extension assumes that all configured databases can be backed up by a single user. Often, the "root" database user will be used. An alternative is to create a separate MySQL "backup" user and grant that user rights to read (but not write) various databases as needed. This second option is probably the best choice.
The extension accepts a username and password in configuration.
However, you probably do not want to provide those values in Cedar Backup
configuration. This is because Cedar Backup will provide these values to
mysqldump
via the command-line --user
and
--password
switches, which will be visible to other users in
the process listing.
/root/.my.cnf
:
[mysqldump] user = root password = <secret>Regardless of whether you are using
~/.my.cnf
or
/etc/cback.conf
to store database login and password
information, you should be careful about who is allowed to view that
information. Typically, this means locking down permissions so that only
the file owner can read the file contents (i.e. use mode
0600
).
Author: Kenneth J. Pronovici <pronovic@ieee.org>
Classes | |
---|---|
LocalConfig |
Class representing this extension's configuration document. |
MysqlConfig |
Class representing MySQL configuration. |
Function Summary | |
---|---|
Backs up an individual MySQL database, or all databases. | |
Executes the MySQL backup action. | |
Backs up an individual MySQL database, or all databases. | |
Opens the output file used for saving the MySQL dump. |
Variable Summary | |
---|---|
Logger |
logger = <logging.Logger instance at 0x403fc08c>
|
list |
MYSQLDUMP_COMMAND = ['mysqldump']
|
Function Details |
---|
backupDatabase(user, password, backupFile, database=None)Backs up an individual MySQL database, or all databases. This function backs up either a named local MySQL database or all local MySQL databases, using the passed-in user and password (if provided) for connectivity. This function call always results a full backup. There is no facility for incremental backups. The backup data will be written into the passed-in backup file.
Normally, this would be an object as returned from Often, the "root" database user will be used when backing up all databases. An alternative is to create a separate MySQL "backup" user and grant that user rights to read (but not write) all of the databases that will be backed up. This function accepts a username and password. However, you probably
do not want to pass those values in. This is because they will be
provided to /root/.my.cnf , to provide
mysqldump with the root database username and its
password:
[mysqldump] user = root password = <secret>If you are executing this function as some system user other than root, then the .my.cnf file would be placed in the home
directory of that user. In either case, make sure to set restrictive
permissions (typically, mode 0600 ) on .my.cnf
to make sure that other users cannot read the file.
|
executeAction(configPath, options, config)Executes the MySQL backup action.
|
_backupDatabase(targetDir, compressMode, user, password, backupUser, backupGroup, database=None)Backs up an individual MySQL database, or all databases. This internal method wraps the public method and adds some functionality, like figuring out a filename, etc.
|
_getOutputFile(targetDir, database, compressMode)Opens the output file used for saving the MySQL dump. The filename is either"mysqldump.txt" or
"mysqldump-<database>.txt" . The
".bz2" extension is added if
compress is True .
|
Variable Details |
---|
logger
|
MYSQLDUMP_COMMAND
|
Home | Trees | Index | Help |
|
---|
Generated by Epydoc 2.1 on Thu Mar 29 20:58:30 2007 | http://epydoc.sf.net |