Пример #1
0
def executeAction(configPath, options, config):
    """
    Executes the split backup action.

    Args:
       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 there are I/O problems reading or writing files
    """
    logger.debug("Executing split extended action.")
    if config.options is None or config.stage is None:
        raise ValueError(
            "Cedar Backup configuration is not properly filled in.")
    local = LocalConfig(xmlPath=configPath)
    dailyDirs = findDailyDirs(config.stage.targetDir, SPLIT_INDICATOR)
    for dailyDir in dailyDirs:
        _splitDailyDir(dailyDir, local.split.sizeLimit, local.split.splitSize,
                       config.options.backupUser, config.options.backupGroup)
        writeIndicatorFile(dailyDir, SPLIT_INDICATOR,
                           config.options.backupUser,
                           config.options.backupGroup)
    logger.info("Executed the split extended action successfully.")
Пример #2
0
def executeAction(configPath, options, config):
    """
    Executes the encrypt backup action.

    Args:
       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 there are I/O problems reading or writing files
    """
    logger.debug("Executing encrypt extended action.")
    if config.options is None or config.stage is None:
        raise ValueError("Cedar Backup configuration is not properly filled in.")
    local = LocalConfig(xmlPath=configPath)
    if local.encrypt.encryptMode not in ["gpg"]:
        raise ValueError("Unknown encrypt mode [%s]" % local.encrypt.encryptMode)
    if local.encrypt.encryptMode == "gpg":
        _confirmGpgRecipient(local.encrypt.encryptTarget)
    dailyDirs = findDailyDirs(config.stage.targetDir, ENCRYPT_INDICATOR)
    for dailyDir in dailyDirs:
        _encryptDailyDir(
            dailyDir, local.encrypt.encryptMode, local.encrypt.encryptTarget, config.options.backupUser, config.options.backupGroup
        )
        writeIndicatorFile(dailyDir, ENCRYPT_INDICATOR, config.options.backupUser, config.options.backupGroup)
    logger.info("Executed the encrypt extended action successfully.")
Пример #3
0
def _findDailyDirs(stagingDir):
    """
    Returns a list of all daily staging directories that have not yet been
    stored.

    The store indicator file ``cback.store`` will be written to a daily staging
    directory once that directory is written to disc.  So, this function looks
    at each daily staging directory within the configured staging directory, and
    returns a list of those which do not contain the indicator file.

    Returned is a tuple containing two items: a list of daily staging
    directories, and a BackupFileList containing all files among those staging
    directories.

    Args:
       stagingDir: Configured staging directory

    Returns:
        Tuple (staging dirs, backup file list)
    """
    results = findDailyDirs(stagingDir, STORE_INDICATOR)
    fileList = BackupFileList()
    for item in results:
        fileList.addDirContents(item)
    return (results, fileList)
Пример #4
0
 def testFindDailyDirs_004(self):
     """
     Test with a staging directory containing only links.
     """
     self.extractTar("tree15")
     stagingDir = self.buildPath(["tree15", "dir001"])
     dailyDirs = findDailyDirs(stagingDir, ENCRYPT_INDICATOR)
     self.assertEqual([], dailyDirs)
Пример #5
0
 def testFindDailyDirs_002(self):
     """
     Test with an empty staging directory.
     """
     self.extractTar("tree8")
     stagingDir = self.buildPath(["tree8", "dir001"])
     dailyDirs = findDailyDirs(stagingDir, ENCRYPT_INDICATOR)
     self.assertEqual([], dailyDirs)
Пример #6
0
 def testFindDailyDirs_006(self):
     """
     Test with a valid staging directory, where the daily directories DO
     contain the encrypt indicator.
     """
     self.extractTar("tree18")
     stagingDir = self.buildPath(["tree18"])
     dailyDirs = findDailyDirs(stagingDir, ENCRYPT_INDICATOR)
     self.assertEqual([], dailyDirs)
Пример #7
0
 def testFindDailyDirs_007(self):
     """
     Test with a valid staging directory, where some daily directories contain
     the encrypt indicator and others do not.
     """
     self.extractTar("tree19")
     stagingDir = self.buildPath(["tree19"])
     dailyDirs = findDailyDirs(stagingDir, ENCRYPT_INDICATOR)
     self.assertEqual(3, len(dailyDirs))
     self.assertTrue(
         self.buildPath(["tree19", "2006", "12", "30"]) in dailyDirs)
     self.assertTrue(
         self.buildPath(["tree19", "2007", "01", "01"]) in dailyDirs)
     self.assertTrue(
         self.buildPath(["tree19", "2007", "01", "03"]) in dailyDirs)
Пример #8
0
 def testFindDailyDirs_008(self):
     """
     Test for case where directories other than daily directories contain the
     encrypt indicator (the indicator should be ignored).
     """
     self.extractTar("tree20")
     stagingDir = self.buildPath(["tree20"])
     dailyDirs = findDailyDirs(stagingDir, ENCRYPT_INDICATOR)
     self.assertEqual(6, len(dailyDirs))
     self.assertTrue(
         self.buildPath(["tree20", "2006", "12", "29"]) in dailyDirs)
     self.assertTrue(
         self.buildPath(["tree20", "2006", "12", "30"]) in dailyDirs)
     self.assertTrue(
         self.buildPath(["tree20", "2006", "12", "31"]) in dailyDirs)
     self.assertTrue(
         self.buildPath(["tree20", "2007", "01", "01"]) in dailyDirs)
     self.assertTrue(
         self.buildPath(["tree20", "2007", "01", "02"]) in dailyDirs)
     self.assertTrue(
         self.buildPath(["tree20", "2007", "01", "03"]) in dailyDirs)
Пример #9
0
 def testFindDailyDirs_005(self):
     """
     Test with a valid staging directory, where the daily directories do NOT
     contain the encrypt indicator.
     """
     self.extractTar("tree17")
     stagingDir = self.buildPath(["tree17"])
     dailyDirs = findDailyDirs(stagingDir, ENCRYPT_INDICATOR)
     self.assertEqual(6, len(dailyDirs))
     self.assertTrue(
         self.buildPath(["tree17", "2006", "12", "29"]) in dailyDirs)
     self.assertTrue(
         self.buildPath(["tree17", "2006", "12", "30"]) in dailyDirs)
     self.assertTrue(
         self.buildPath(["tree17", "2006", "12", "31"]) in dailyDirs)
     self.assertTrue(
         self.buildPath(["tree17", "2007", "01", "01"]) in dailyDirs)
     self.assertTrue(
         self.buildPath(["tree17", "2007", "01", "02"]) in dailyDirs)
     self.assertTrue(
         self.buildPath(["tree17", "2007", "01", "03"]) in dailyDirs)