def backup_main(bin_dir, storages, keep, full,
                verbose, gzip, backup_blobs, only_blobs, use_rsync,
                keep_blob_days=0, pre_command='', post_command='', **kwargs):
    """Main method, gets called by generated bin/backup."""
    utils.execute_or_fail(pre_command)
    if not only_blobs:
        result = repozorunner.backup_main(
            bin_dir, storages, keep, full, verbose, gzip)
        if result and backup_blobs:
            logger.error("Halting execution due to error; not backing up "
                         "blobs.")

    if not backup_blobs:
        utils.execute_or_fail(post_command)
        return
    for storage in storages:
        blobdir = storage['blobdir']
        if not blobdir:
            logger.info("No blob dir defined for %s storage" % \
                                                (storage['storage']))
            continue
        blob_backup_location = storage['blob_backup_location']
        logger.info("Please wait while backing up blobs from %s to %s",
                    blobdir, blob_backup_location)
        copyblobs.backup_blobs(blobdir, blob_backup_location, full,                            
                               use_rsync, keep=keep, keep_blob_days=keep_blob_days,)
    utils.execute_or_fail(post_command)
Example #2
0
def backup_main(bin_dir,
                storages,
                keep,
                full,
                verbose,
                gzip,
                backup_blobs,
                only_blobs,
                use_rsync,
                keep_blob_days=0,
                pre_command='',
                post_command='',
                gzip_blob=False,
                rsync_options='',
                quick=True,
                **kwargs):
    """Main method, gets called by generated bin/backup."""
    utils.check_folders(storages,
                        backup_blobs=backup_blobs,
                        only_blobs=only_blobs,
                        backup=True,
                        snapshot=False,
                        zipbackup=False)
    utils.execute_or_fail(pre_command)
    if not only_blobs:
        result = repozorunner.backup_main(bin_dir, storages, keep, full,
                                          verbose, gzip, quick)
        if result:
            if backup_blobs:
                logger.error("Halting execution due to error; not backing up "
                             "blobs.")
            else:
                logger.error("Halting execution due to error.")
            sys.exit(1)

    if not backup_blobs:
        utils.execute_or_fail(post_command)
        return
    for storage in storages:
        blobdir = storage['blobdir']
        if not blobdir:
            logger.info("No blob dir defined for %s storage" %
                        storage['storage'])
            continue
        blob_backup_location = storage['blob_backup_location']
        logger.info("Please wait while backing up blobs from %s to %s",
                    blobdir, blob_backup_location)
        copyblobs.backup_blobs(blobdir,
                               blob_backup_location,
                               full,
                               use_rsync,
                               keep=keep,
                               keep_blob_days=keep_blob_days,
                               gzip_blob=gzip_blob,
                               rsync_options=rsync_options)
    utils.execute_or_fail(post_command)
Example #3
0
def backup_main(bin_dir, datafs, backup_location, keep, full, verbose, gzip,
                additional, blob_storage_source, backup_blobs, only_blobs,
                **kwargs):
    """Main method, gets called by generated bin/backup."""
    if not only_blobs:
        result = repozorunner.backup_main(
            bin_dir, datafs, backup_location, keep, full, verbose, gzip,
            additional)
        if result and backup_blobs:
            logger.error("Halting execution due to error; not backing up "
                         "blobs.")

    if not backup_blobs:
        return
    if not blob_storage_source:
        logger.error("No blob storage source specified")
        sys.exit(1)
    result = repoborunner.backup_main(bin_dir, blob_storage_source,
                                      backup_location, keep, full, verbose,
                                      gzip)
Example #4
0
def backup_main(bin_dir, storages, keep, full,
                verbose, gzip, backup_blobs, only_blobs, use_rsync,
                keep_blob_days=0, pre_command='', post_command='',
                gzip_blob=False, rsync_options='', quick=True, **kwargs):
    """Main method, gets called by generated bin/backup."""
    utils.check_folders(storages, backup_blobs=backup_blobs,
                        only_blobs=only_blobs, backup=True,
                        snapshot=False, zipbackup=False)
    utils.execute_or_fail(pre_command)
    if not only_blobs:
        result = repozorunner.backup_main(
            bin_dir, storages, keep, full, verbose, gzip, quick)
        if result:
            if backup_blobs:
                logger.error("Halting execution due to error; not backing up "
                             "blobs.")
            else:
                logger.error("Halting execution due to error.")
            sys.exit(1)

    if not backup_blobs:
        utils.execute_or_fail(post_command)
        return
    for storage in storages:
        blobdir = storage['blobdir']
        if not blobdir:
            logger.info("No blob dir defined for %s storage" %
                        storage['storage'])
            continue
        blob_backup_location = storage['blob_backup_location']
        logger.info("Please wait while backing up blobs from %s to %s",
                    blobdir, blob_backup_location)
        copyblobs.backup_blobs(blobdir, blob_backup_location, full,
                               use_rsync, keep=keep,
                               keep_blob_days=keep_blob_days,
                               gzip_blob=gzip_blob,
                               rsync_options=rsync_options)
    utils.execute_or_fail(post_command)
def backup_main(
    bin_dir,
    storages,
    keep,
    full,
    verbose,
    gzip,
    backup_blobs,
    only_blobs,
    use_rsync,
    keep_blob_days=0,
    pre_command="",
    post_command="",
    archive_blob=False,
    compress_blob=False,
    rsync_options="",
    quick=True,
    blob_timestamps=False,
    backup_method=config.STANDARD_BACKUP,
    incremental_blobs=False,
    **kwargs
):
    """Main method, gets called by generated bin/backup."""
    if backup_method not in config.BACKUP_METHODS:
        raise RuntimeError("Unknown backup method {0}.".format(backup_method))
    utils.execute_or_fail(pre_command)
    utils.check_folders(
        storages,
        backup_blobs=backup_blobs,
        only_blobs=only_blobs,
        backup_method=backup_method,
    )
    if not only_blobs:
        result = repozorunner.backup_main(
            bin_dir, storages, keep, full, verbose, gzip, quick, backup_method
        )
        if result:
            if backup_blobs:
                logger.error("Halting execution due to error; not backing up blobs.")
            else:
                logger.error("Halting execution due to error.")
            sys.exit(1)

    if not backup_blobs:
        utils.execute_or_fail(post_command)
        return
    for storage in storages:
        blobdir = storage["blobdir"]
        if not blobdir:
            logger.info("No blob dir defined for %s storage", storage["storage"])
            continue
        blob_backup_location = None
        if backup_method == config.STANDARD_BACKUP:
            blob_backup_location = storage["blob_backup_location"]
            logger.info(
                "Please wait while backing up blobs from %s to %s",
                blobdir,
                blob_backup_location,
            )
        elif backup_method == config.SNAPSHOT_BACKUP:
            blob_backup_location = storage["blob_snapshot_location"]
            logger.info(
                "Please wait while making snapshot of blobs from %s to %s",
                blobdir,
                blob_backup_location,
            )
        elif backup_method == config.ZIP_BACKUP:
            blob_backup_location = storage["blob_zip_location"]
            logger.info(
                "Please wait while backing up blobs from %s to %s",
                blobdir,
                blob_backup_location,
            )
        if only_blobs:
            fs_backup_location = None
        else:
            fs_backup_location = storage["backup_location"]
        copyblobs.backup_blobs(
            blobdir,
            blob_backup_location,
            full,
            use_rsync,
            keep=keep,
            keep_blob_days=keep_blob_days,
            archive_blob=archive_blob,
            compress_blob=compress_blob,
            rsync_options=rsync_options,
            timestamps=blob_timestamps,
            fs_backup_location=fs_backup_location,
            incremental_blobs=incremental_blobs,
        )
    utils.execute_or_fail(post_command)
Example #6
0
def backup_main(
        bin_dir,
        storages,
        keep,
        full,
        verbose,
        gzip,
        backup_blobs,
        only_blobs,
        use_rsync,
        keep_blob_days=0,
        pre_command='',
        post_command='',
        archive_blob=False,
        compress_blob=False,
        rsync_options='',
        quick=True,
        blob_timestamps=False,
        backup_method=config.STANDARD_BACKUP,
        incremental_blobs=False,
        **kwargs):
    """Main method, gets called by generated bin/backup."""
    if backup_method not in config.BACKUP_METHODS:
        raise RuntimeError('Unknown backup method {0}.'.format(backup_method))
    utils.execute_or_fail(pre_command)
    utils.check_folders(
        storages,
        backup_blobs=backup_blobs,
        only_blobs=only_blobs,
        backup_method=backup_method,
    )
    if not only_blobs:
        result = repozorunner.backup_main(
            bin_dir, storages, keep, full, verbose, gzip, quick,
            backup_method,
        )
        if result:
            if backup_blobs:
                logger.error(
                    'Halting execution due to error; not backing up blobs.')
            else:
                logger.error('Halting execution due to error.')
            sys.exit(1)

    if not backup_blobs:
        utils.execute_or_fail(post_command)
        return
    for storage in storages:
        blobdir = storage['blobdir']
        if not blobdir:
            logger.info(
                'No blob dir defined for %s storage', storage['storage'])
            continue
        blob_backup_location = None
        if backup_method == config.STANDARD_BACKUP:
            blob_backup_location = storage['blob_backup_location']
            logger.info(
                'Please wait while backing up blobs from %s to %s',
                blobdir, blob_backup_location)
        elif backup_method == config.SNAPSHOT_BACKUP:
            blob_backup_location = storage['blob_snapshot_location']
            logger.info(
                'Please wait while making snapshot of blobs from %s to %s',
                blobdir, blob_backup_location)
        elif backup_method == config.ZIP_BACKUP:
            blob_backup_location = storage['blob_zip_location']
            logger.info(
                'Please wait while backing up blobs from %s to %s',
                blobdir, blob_backup_location)
        if only_blobs:
            fs_backup_location = None
        else:
            fs_backup_location = storage['backup_location']
        copyblobs.backup_blobs(
            blobdir,
            blob_backup_location,
            full,
            use_rsync,
            keep=keep,
            keep_blob_days=keep_blob_days,
            archive_blob=archive_blob,
            compress_blob=compress_blob,
            rsync_options=rsync_options,
            timestamps=blob_timestamps,
            fs_backup_location=fs_backup_location,
            incremental_blobs=incremental_blobs,
        )
    utils.execute_or_fail(post_command)