Exemplo n.º 1
0
def execute(state):

    # Restore tracking DB from storage, ignore possible error
    err, msg = storager.restore(
            state.states.storager,
            "{}/{}".format(state.model.dirstorage, '_aeroback'),
            state.states.dbr.model.dir_db,
            state.states.dbr.model.filename,
            None)
    if err:
        warn = "Backup {}: File Versioned Tracking DB not found in storage. Ignore if that's the first run".format(state.model.atype)
        state.add_msg_warning(warn)
        _D.WARNING(
                __name__,
                warn,
                'msg', msg
                )

    # Tracking DBr execute
    err, msg = dbr.execute(state.states.dbr)
    if err:
        return 1, msg

    # Compress directories
    err, msg = _archive_dirs(state)
    if err:
        return 1, "Error archiving dirs: {}".format(msg)

    # Store archive
    err, msg = _store_archive(state)
    if err:
        return 1, msg

    return 0, None
Exemplo n.º 2
0
def execute(state):

    # Restore tracking DB from storage, ignore possible error
    err, msg = storager.restore(
            state.states.storager,
            "{}/{}".format(state.model.dirstorage, '_aeroback'),
            state.states.dbr.model.dir_db,
            state.states.dbr.model.filename,
            None)
    if err:
        warn = "Backup {}: File Incremental Tracking DB not found in storage. Ignore if that's the first run".format(state.model.atype)
        state.add_msg_warning(warn)
        _D.WARNING(
                __name__,
                warn,
                'msg', msg
                )

    # Tracking DBr execute
    err, msg = dbr.execute(state.states.dbr)
    if err:
        return 1, msg

    # Update DB params
    dbr.update_params(state.states.dbr, state.model.directory, state.model.dirstorage)

    # Clear DB list of local files and files to be uploaded
    dbr.clear_locals_uploads(state.states.dbr)

    # Scan local files and add them to DB
    err, msg = _scan_local_files(state)
    if err:
        state.add_msg_error(msg)

    # Find differences
    err, msg = dbr.find_local_storage_diff(state.states.dbr, state.model.maxupload)
    if err:
        state.add_msg_error(msg)

    # Store differences
    err, msg = _store(state)
    if err:
        state.add_msg_error(msg)

    return 0, None
Exemplo n.º 3
0
def execute(state):
    # Restore tracking DB from storage, ignore possible error
    err, msg = storager.restore(
        state.states.storager,
        state.model.dirstorage,
        state.states.dbr.model.dir_db,
        state.states.dbr.model.filename,
        None,
    )
    if err:
        warn = "Backup {}: Tracking DB not found in storage. Ignore if that's the first run".format(state.model.atype)
        state.add_msg_warning(warn)
        _D.WARNING(__name__, warn, "msg", msg)

    # Tracking DBr execute
    err, msg = dbr.execute(state.states.dbr)
    if err:
        return 1, msg

    # Dump DB
    if state.model.atype == "db_mongo":
        err, msg = _dump_db_mongo(state)
    elif state.model.atype == "db_mysql":
        err, msg = _dump_db_mysql(state)
    else:
        return 1, "Not supported DB type: {}".format(state.model.atype)

    if err:
        return 1, msg

    # Compress DB dump directory
    err, msg = _archive_dump(state)
    if err:
        return 1, msg

    # Store DB archive
    err, msg = _store_archive(state)
    if err:
        return 1, msg

    return 0, None