CedarBackup3.extend.subversion
¶
Provides an extension to back up Subversion repositories.
This is a Cedar Backup extension used to back up Subversion repositories via the Cedar Backup command line. Each Subversion repository can be backed using the same collect modes allowed for filesystems in the standard Cedar Backup collect action: weekly, daily, incremental.
This extension requires a new configuration section <subversion> 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.
There are two different kinds of Subversion repositories at this writing: BDB
(Berkeley Database) and FSFS (a “filesystem within a filesystem”). Although
the repository type can be specified in configuration, that information is just
kept around for reference. It doesn’t affect the backup. Both kinds of
repositories are backed up in the same way, using svnadmin dump
in an
incremental mode.
It turns out that FSFS repositories can also be backed up just like any other filesystem directory. If you would rather do that, then use the normal collect action. This is probably simpler, although it carries its own advantages and disadvantages (plus you will have to be careful to exclude the working directories Subversion uses when building an update to commit). Check the Subversion documentation for more information.
- author
Kenneth J. Pronovici <pronovic@ieee.org>
Module Contents¶
- CedarBackup3.extend.subversion.logger¶
- CedarBackup3.extend.subversion.SVNLOOK_COMMAND = ['svnlook']¶
- CedarBackup3.extend.subversion.SVNADMIN_COMMAND = ['svnadmin']¶
- CedarBackup3.extend.subversion.REVISION_PATH_EXTENSION = svnlast¶
- class CedarBackup3.extend.subversion.RepositoryDir(repositoryType=None, directoryPath=None, collectMode=None, compressMode=None, relativeExcludePaths=None, excludePatterns=None)¶
Bases:
object
Class representing Subversion repository directory.
A repository directory is a directory that contains one or more Subversion repositories.
The following restrictions exist on data in this class:
The directory path must be absolute.
The collect mode must be one of the values in
VALID_COLLECT_MODES
.The compress mode must be one of the values in
VALID_COMPRESS_MODES
.
The repository type value is kept around just for reference. It doesn’t affect the behavior of the backup.
Relative exclusions are allowed here. However, there is no configured ignore file, because repository dir backups are not recursive.
- repositoryType¶
- directoryPath¶
- collectMode¶
- compressMode¶
- relativeExcludePaths¶
- excludePatterns¶
- __repr__()¶
Official string representation for class instance.
- __str__()¶
Informal string representation for class instance.
- __eq__(other)¶
Equals operator, iplemented in terms of original Python 2 compare operator.
- __lt__(other)¶
Less-than operator, iplemented in terms of original Python 2 compare operator.
- __gt__(other)¶
Greater-than operator, iplemented in terms of original Python 2 compare operator.
- __cmp__(other)¶
Original Python 2 comparison operator. :param other: Other object to compare to
- Returns
-1/0/1 depending on whether self is
<
,=
or>
other
- class CedarBackup3.extend.subversion.Repository(repositoryType=None, repositoryPath=None, collectMode=None, compressMode=None)¶
Bases:
object
Class representing generic Subversion repository configuration..
The following restrictions exist on data in this class:
The respository path must be absolute.
The collect mode must be one of the values in
VALID_COLLECT_MODES
.The compress mode must be one of the values in
VALID_COMPRESS_MODES
.
The repository type value is kept around just for reference. It doesn’t affect the behavior of the backup.
- repositoryType¶
- repositoryPath¶
- collectMode¶
- compressMode¶
- __repr__()¶
Official string representation for class instance.
- __str__()¶
Informal string representation for class instance.
- __eq__(other)¶
Equals operator, iplemented in terms of original Python 2 compare operator.
- __lt__(other)¶
Less-than operator, iplemented in terms of original Python 2 compare operator.
- __gt__(other)¶
Greater-than operator, iplemented in terms of original Python 2 compare operator.
- __cmp__(other)¶
Original Python 2 comparison operator. :param other: Other object to compare to
- Returns
-1/0/1 depending on whether self is
<
,=
or>
other
- class CedarBackup3.extend.subversion.SubversionConfig(collectMode=None, compressMode=None, repositories=None, repositoryDirs=None)¶
Bases:
object
Class representing Subversion configuration.
Subversion configuration is used for backing up Subversion repositories.
The following restrictions exist on data in this class:
The collect mode must be one of the values in
VALID_COLLECT_MODES
.The compress mode must be one of the values in
VALID_COMPRESS_MODES
.The repositories list must be a list of
Repository
objects.The repositoryDirs list must be a list of
RepositoryDir
objects.
For the two lists, validation is accomplished through the
util.ObjectTypeList
list implementation that overrides common list methods and transparently ensures that each element has the correct type.Note: Lists within this class are “unordered” for equality comparisons.
- collectMode¶
- compressMode¶
- repositories¶
- repositoryDirs¶
- __repr__()¶
Official string representation for class instance.
- __str__()¶
Informal string representation for class instance.
- __eq__(other)¶
Equals operator, iplemented in terms of original Python 2 compare operator.
- __lt__(other)¶
Less-than operator, iplemented in terms of original Python 2 compare operator.
- __gt__(other)¶
Greater-than operator, iplemented in terms of original Python 2 compare operator.
- __cmp__(other)¶
Original Python 2 comparison operator. Lists within this class are “unordered” for equality comparisons. :param other: Other object to compare to
- Returns
-1/0/1 depending on whether self is
<
,=
or>
other
- class CedarBackup3.extend.subversion.LocalConfig(xmlData=None, xmlPath=None, validate=True)¶
Bases:
object
Class representing this extension’s configuration document.
This is not a general-purpose configuration object like the main Cedar Backup configuration object. Instead, it just knows how to parse and emit Subversion-specific configuration values. Third parties who need to read and write configuration related to this extension should access it through the constructor,
validate
andaddConfig
methods.Note: Lists within this class are “unordered” for equality comparisons.
- subversion¶
- __repr__()¶
Official string representation for class instance.
- __str__()¶
Informal string representation for class instance.
- __eq__(other)¶
Equals operator, iplemented in terms of original Python 2 compare operator.
- __lt__(other)¶
Less-than operator, iplemented in terms of original Python 2 compare operator.
- __gt__(other)¶
Greater-than operator, iplemented in terms of original Python 2 compare operator.
- __cmp__(other)¶
Original Python 2 comparison operator. Lists within this class are “unordered” for equality comparisons. :param other: Other object to compare to
- Returns
-1/0/1 depending on whether self is
<
,=
or>
other
- validate()¶
Validates configuration represented by the object.
Subversion configuration must be filled in. Within that, the collect mode and compress mode are both optional, but the list of repositories must contain at least one entry.
Each repository must contain a repository path, and then must be either able to take collect mode and compress mode configuration from the parent
SubversionConfig
object, or must set each value on its own.- Raises
ValueError – If one of the validations fails
- addConfig(xmlDom, parentNode)¶
Adds a <subversion> configuration section as the next child of a parent.
Third parties should use this function to write configuration related to this extension.
We add the following fields to the document:
collectMode //cb_config/subversion/collectMode compressMode //cb_config/subversion/compressMode
We also add groups of the following items, one list element per item:
repository //cb_config/subversion/repository repository_dir //cb_config/subversion/repository_dir
- Parameters
xmlDom – DOM tree as from
impl.createDocument()
parentNode – Parent that the section should be appended to
- CedarBackup3.extend.subversion.executeAction(configPath, options, config)¶
Executes the Subversion backup action.
- Parameters
configPath (String representing a path on disk) – Path to configuration file on disk
options (Options object) – Program command-line options
config (Config object) – Program configuration
- Raises
ValueError – Under many generic error conditions
IOError – If a backup could not be written for some reason
- CedarBackup3.extend.subversion.backupRepository(repositoryPath, backupFile, startRevision=None, endRevision=None)¶
Backs up an individual Subversion repository.
The starting and ending revision values control an incremental backup. If the starting revision is not passed in, then revision zero (the start of the repository) is assumed. If the ending revision is not passed in, then the youngest revision in the database will be used as the endpoint.
The backup data will be written into the passed-in back file. Normally, this would be an object as returned from
open
, but it is possible to use something like aGzipFile
to write compressed output. The caller is responsible for closing the passed-in backup file.Note: This function should either be run as root or as the owner of the Subversion repository.
Note: It is apparently not a good idea to interrupt this function. Sometimes, this leaves the repository in a “wedged” state, which requires recovery using
svnadmin recover
.- Parameters
repositoryPath (String path representing Subversion repository on disk) – Path to Subversion repository to back up
backupFile (Python file object as from
open
orfile
) – Python file object to use for writing backupstartRevision (Integer value >= 0) – Starting repository revision to back up (for incremental backups)
endRevision (Integer value >= 0) – Ending repository revision to back up (for incremental backups)
- Raises
ValueError – If some value is missing or invalid
IOError – If there is a problem executing the Subversion dump
- CedarBackup3.extend.subversion.getYoungestRevision(repositoryPath)¶
Gets the youngest (newest) revision in a Subversion repository using
svnlook
.Note: This function should either be run as root or as the owner of the Subversion repository.
- Parameters
repositoryPath (String path representing Subversion repository on disk) – Path to Subversion repository to look in
- Returns
Youngest revision as an integer
- Raises
ValueError – If there is a problem parsing the
svnlook
outputIOError – If there is a problem executing the
svnlook
command
- class CedarBackup3.extend.subversion.BDBRepository(repositoryPath=None, collectMode=None, compressMode=None)¶
Bases:
Repository
Class representing Subversion BDB (Berkeley Database) repository configuration. This object is deprecated. Use a simple
Repository
instead.- __repr__()¶
Official string representation for class instance.
- class CedarBackup3.extend.subversion.FSFSRepository(repositoryPath=None, collectMode=None, compressMode=None)¶
Bases:
Repository
Class representing Subversion FSFS repository configuration. This object is deprecated. Use a simple
Repository
instead.- __repr__()¶
Official string representation for class instance.
- CedarBackup3.extend.subversion.backupBDBRepository(repositoryPath, backupFile, startRevision=None, endRevision=None)¶
Backs up an individual Subversion BDB repository. This function is deprecated. Use
backupRepository
instead.
- CedarBackup3.extend.subversion.backupFSFSRepository(repositoryPath, backupFile, startRevision=None, endRevision=None)¶
Backs up an individual Subversion FSFS repository. This function is deprecated. Use
backupRepository
instead.