Exemplo n.º 1
0
def _changeTarget(jobType, target, dictParams):
    verifyBackendWithNameSpaceType(target)
    testConfiguration()
    jobID = jobType + "_job_" + str(uuid.uuid1())
    logger.info("Starting %s" % jobID)
    with auxiliary.cleanedUpDir(os.path.join(env.tmpDir, jobID),
                                cleanupOnException=True) as tmpDir:
        targetCfg = auxiliary.recursiveOverlayDict(target.getJSONDict(),
                                                   dictParams)
        prepareEnvironment(jobID, tmpDir, None, targetCfg)
        runInEnvironment(tmpDir, [RESTORE_BINARY], jobID)
Exemplo n.º 2
0
def backup(source, target, startSnapshot=None, endSnapshot=None):
    """ Creates a backup of the source volume to the target
        The target namespace must exist. If it already contains a backup volume, an incremental backup is applied.
        @param source : BackendWithNamespace
        @param target : BackendWithNamespace
    """
    verifyBackendWithNameSpaceType(target)
    jobID = "backup_job_" + str(uuid.uuid1())
    logger.info("Starting ID %s" % jobID)
    with auxiliary.cleanedUpDir(os.path.join(env.tmpDir, jobID),
                                cleanupOnException=True) as tmpDir:
        prepareEnvironment(jobID, tmpDir, source.getJSONDict(),
                           target.getJSONDict(), startSnapshot, endSnapshot)
        runInEnvironment(tmpDir, [BACKUP_BINARY], jobID)
Exemplo n.º 3
0
def copy(source, target):
    """ Copies the backup in the source to the target
        @param source : BackendWithNamespace
        @param target : BackendWithNamespace
    """
    verifyBackendWithNameSpaceType(target)
    testConfiguration()
    jobID = "copy_job_" + str(uuid.uuid1())
    logger.info("Starting %s" % jobID)
    with auxiliary.cleanedUpDir(os.path.join(env.tmpDir, jobID),
                                cleanupOnException=True) as tmpDir:
        prepareEnvironment(jobID, tmpDir, source.getJSONDict(),
                           target.getJSONDict())

        runInEnvironment(tmpDir, [RESTORE_BINARY], jobID)
Exemplo n.º 4
0
def _changeTarget(jobType, target, dictParams):
    verifyBackendWithNameSpaceType(target)
    testConfiguration()
    jobID = jobType + "_job_" + str(uuid.uuid1())
    logger.info("Starting %s" % jobID)
    with auxiliary.cleanedUpDir(os.path.join(env.tmpDir,
                                             jobID),
                                cleanupOnException=True) as tmpDir:
        targetCfg = auxiliary.recursiveOverlayDict(target.getJSONDict(),
                                                   dictParams)
        prepareEnvironment(jobID,
                           tmpDir,
                           None,
                           targetCfg)
        runInEnvironment(tmpDir, [RESTORE_BINARY], jobID)
Exemplo n.º 5
0
def deleteSnapshots(target, snapshots):
    """Delete the snapshots on the backup target
       @param target: BackendWithNamespace
       @param snapshots: list of snapshots to delete
    """
    verifyBackendWithNameSpaceType(target)
    if snapshots != []:
        jobID = "deletesnapshots_job_" + str(uuid.uuid1())
        logger.info("Starting %s" % jobID)

        with auxiliary.cleanedUpDir(os.path.join(env.tmpDir, jobID),
                                    cleanupOnException=True) as tmpDir:
            prepareEnvironment(jobID, tmpDir, {}, target.getJSONDict())
            runInEnvironment(tmpDir, [BACKUP_BINARY] +
                             ["--delete-snapshot=" + s for s in snapshots],
                             jobID)
Exemplo n.º 6
0
def copy(source, target):
    """ Copies the backup in the source to the target
        @param source : BackendWithNamespace
        @param target : BackendWithNamespace
    """
    verifyBackendWithNameSpaceType(target)
    testConfiguration()
    jobID = "copy_job_" + str(uuid.uuid1())
    logger.info("Starting %s" % jobID)
    with auxiliary.cleanedUpDir(os.path.join(env.tmpDir,
                                             jobID),
                                cleanupOnException=True) as tmpDir:
        prepareEnvironment(jobID,
                           tmpDir,
                           source.getJSONDict(),
                           target.getJSONDict())

        runInEnvironment(tmpDir, [RESTORE_BINARY], jobID)
Exemplo n.º 7
0
def backup(source, target, startSnapshot=None, endSnapshot=None):
    """ Creates a backup of the source volume to the target
        The target namespace must exist. If it already contains a backup volume, an incremental backup is applied.
        @param source : BackendWithNamespace
        @param target : BackendWithNamespace
    """
    verifyBackendWithNameSpaceType(target)
    jobID = "backup_job_" + str(uuid.uuid1())
    logger.info("Starting ID %s" % jobID)
    with auxiliary.cleanedUpDir(os.path.join(env.tmpDir,
                                             jobID),
                                cleanupOnException=True) as tmpDir:
        prepareEnvironment(jobID,
                           tmpDir,
                           source.getJSONDict(),
                           target.getJSONDict(),
                           startSnapshot,
                           endSnapshot)
        runInEnvironment(tmpDir, [BACKUP_BINARY], jobID)
Exemplo n.º 8
0
def deleteSnapshots(target, snapshots):
    """Delete the snapshots on the backup target
       @param target: BackendWithNamespace
       @param snapshots: list of snapshots to delete
    """
    verifyBackendWithNameSpaceType(target)
    if snapshots != []:
        jobID = "deletesnapshots_job_" + str(uuid.uuid1())
        logger.info("Starting %s" % jobID)

        with auxiliary.cleanedUpDir(os.path.join(env.tmpDir,
                                                 jobID),
                                    cleanupOnException=True) as tmpDir:
            prepareEnvironment(jobID,
                               tmpDir,
                               {},
                               target.getJSONDict())
            runInEnvironment(tmpDir,
                             [BACKUP_BINARY] + [
                                 "--delete-snapshot=" + s for s in snapshots],
                             jobID)