Package CedarBackup2 :: Package actions :: Module collect
[show private | hide private]
[frames | no frames]

Module CedarBackup2.actions.collect

Implements the standard 'collect' action.

Author: Kenneth J. Pronovici <pronovic@ieee.org>

Function Summary
  executeCollect(configPath, options, config)
Executes the collect backup action.
  _collectDirectory(config, absolutePath, tarfilePath, collectMode, archiveMode, ignoreFile, resetDigest, digestPath, excludePaths, excludePatterns)
Collects a configured collect directory.
  _collectFile(config, absolutePath, tarfilePath, collectMode, archiveMode, resetDigest, digestPath)
Collects a configured collect file.
  _executeBackup(config, backupList, absolutePath, tarfilePath, collectMode, archiveMode, resetDigest, digestPath)
Execute the backup process for the indicated backup list.
  _getArchiveMode(config, item)
Gets the archive mode that should be used for a collect directory or file.
  _getCollectMode(config, item)
Gets the collect mode that should be used for a collect directory or file.
  _getDigestPath(config, item)
Gets the digest path associated with a collect directory or file.
  _getExclusions(config, collectDir)
Gets exclusions (file and patterns) associated with a collect directory.
  _getIgnoreFile(config, item)
Gets the ignore file that should be used for a collect directory or file.
  _getTarfilePath(config, item, archiveMode)
Gets the tarfile path (including correct extension) associated with a collect directory.
  _loadDigest(digestPath)
Loads the indicated digest path from disk into a dictionary.
  _writeDigest(config, digest, digestPath)
Writes the digest dictionary to the indicated digest path on disk.

Variable Summary
Logger logger = <logging.Logger instance at 0x402c494c>

Function Details

executeCollect(configPath, options, config)

Executes the collect backup action.
Parameters:
configPath - Path to configuration file on disk.
           (type=String representing a path on disk.)
options - Program command-line options.
           (type=Options object.)
config - Program configuration.
           (type=Config object.)
Raises:
ValueError - Under many generic error conditions
TarError - If there is a problem creating a tar file

Note: When the collect action is complete, we will write a collect indicator to the collect directory, so it's obvious that the collect action has completed. The stage process uses this indicator to decide whether a peer is ready to be staged.

_collectDirectory(config, absolutePath, tarfilePath, collectMode, archiveMode, ignoreFile, resetDigest, digestPath, excludePaths, excludePatterns)

Collects a configured collect directory.

The indicated collect directory is collected into the indicated tarfile. For directories that are collected incrementally, we'll use the indicated digest path and pay attention to the reset digest flag (basically, the reset digest flag ignores any existing digest, but a new digest is always rewritten).

The caller must decide what the collect and archive modes are, since they can be on both the collect configuration and the collect directory itself.
Parameters:
config - Config object.
absolutePath - Absolute path of directory to collect.
tarfilePath - Path to tarfile that should be created.
collectMode - Collect mode to use.
archiveMode - Archive mode to use.
ignoreFile - Ignore file to use.
resetDigest - Reset digest flag.
digestPath - Path to digest file on disk, if needed.
excludePaths - List of absolute paths to exclude.
excludePatterns - List of patterns to exclude.

_collectFile(config, absolutePath, tarfilePath, collectMode, archiveMode, resetDigest, digestPath)

Collects a configured collect file.

The indicated collect file is collected into the indicated tarfile. For files that are collected incrementally, we'll use the indicated digest path and pay attention to the reset digest flag (basically, the reset digest flag ignores any existing digest, but a new digest is always rewritten).

The caller must decide what the collect and archive modes are, since they can be on both the collect configuration and the collect file itself.
Parameters:
config - Config object.
absolutePath - Absolute path of file to collect.
tarfilePath - Path to tarfile that should be created.
collectMode - Collect mode to use.
archiveMode - Archive mode to use.
resetDigest - Reset digest flag.
digestPath - Path to digest file on disk, if needed.

_executeBackup(config, backupList, absolutePath, tarfilePath, collectMode, archiveMode, resetDigest, digestPath)

Execute the backup process for the indicated backup list.

This function exists mainly to consolidate functionality between the _collectFile and _collectDirectory functions. Those functions build the backup list; this function causes the backup to execute properly and also manages usage of the digest file on disk as explained in their comments.

For collect files, the digest file will always just contain the single file that is being backed up. This might little wasteful in terms of the number of files that we keep around, but it's consistent and easy to understand.
Parameters:
config - Config object.
backupList - List to execute backup for
absolutePath - Absolute path of directory or file to collect.
tarfilePath - Path to tarfile that should be created.
collectMode - Collect mode to use.
archiveMode - Archive mode to use.
resetDigest - Reset digest flag.
digestPath - Path to digest file on disk, if needed.

_getArchiveMode(config, item)

Gets the archive mode that should be used for a collect directory or file. If possible, use the one on the file or directory, otherwise take from collect section.
Parameters:
config - Config object.
item - CollectFile or CollectDir object
Returns:
Archive mode to use.

_getCollectMode(config, item)

Gets the collect mode that should be used for a collect directory or file. If possible, use the one on the file or directory, otherwise take from collect section.
Parameters:
config - Config object.
item - CollectFile or CollectDir object
Returns:
Collect mode to use.

_getDigestPath(config, item)

Gets the digest path associated with a collect directory or file.
Parameters:
config - Config object.
item - CollectFile or CollectDir object
Returns:
Absolute path to the digest associated with the collect directory or file.

_getExclusions(config, collectDir)

Gets exclusions (file and patterns) associated with a collect directory.

The returned files value is a list of absolute paths to be excluded from the backup for a given directory. It is derived from the collect configuration absolute exclude paths and the collect directory's absolute and relative exclude paths.

The returned patterns value is a list of patterns to be excluded from the backup for a given directory. It is derived from the list of patterns from the collect configuration and from the collect directory itself.
Parameters:
config - Config object.
collectDir - Collect directory object.
Returns:
Tuple (files, patterns) indicating what to exclude.

_getIgnoreFile(config, item)

Gets the ignore file that should be used for a collect directory or file. If possible, use the one on the file or directory, otherwise take from collect section.
Parameters:
config - Config object.
item - CollectFile or CollectDir object
Returns:
Ignore file to use.

_getTarfilePath(config, item, archiveMode)

Gets the tarfile path (including correct extension) associated with a collect directory.
Parameters:
config - Config object.
item - CollectFile or CollectDir object
archiveMode - Archive mode to use for this tarfile.
Returns:
Absolute path to the tarfile associated with the collect directory.

_loadDigest(digestPath)

Loads the indicated digest path from disk into a dictionary.

If we can't load the digest successfully (either because it doesn't exist or for some other reason), then an empty dictionary will be returned - but the condition will be logged.
Parameters:
digestPath - Path to the digest file on disk.
Returns:
Dictionary representing contents of digest path.

_writeDigest(config, digest, digestPath)

Writes the digest dictionary to the indicated digest path on disk.

If we can't write the digest successfully for any reason, we'll log the condition but won't throw an exception.
Parameters:
config - Config object.
digest - Digest dictionary to write to disk.
digestPath - Path to the digest file on disk.

Variable Details

logger

Type:
Logger
Value:
<logging.Logger instance at 0x402c494c>                                

Generated by Epydoc 2.1 on Thu Mar 29 20:58:26 2007 http://epydoc.sf.net