Пример #1
0
def prune(config, section):
    opts = list(
        extract_borg_commands_opts(
            config, 'prune', section,
            ['dry-run', 'force', 's', 'stats', 'list', 'save-space'], []))
    log('running: borg prune', *opts)
    borg('prune', *opts)()
Пример #2
0
 def test(passphrase):
     code = (echo(passphrase) | borg('info',
                                     repo,
                                     env={'BORG_PASSPHRASE_FD': '0'},
                                     stdout=NULL,
                                     raise_on_error=False))()[0]
     return code == 0
Пример #3
0
def parse_args(argv):
    if not os.environ.get('SYBORG_CONFIG'):
        os.environ['SYBORG_CONFIG'] = '{}/syborg/syborg.cfg'.format(
            xdg_config_home)
    parser = argparse.ArgumentParser()
    parser.add_argument('--config',
                        default=os.environ['SYBORG_CONFIG'],
                        help='syborg main config file')
    subparsers = parser.add_subparsers()
    subparsers.required = True
    subparsers.dest = 'command'
    parse_backup(subparsers)
    parse_wrapped_command(subparsers, 'list', borg('list'))
    parse_wrapped_command(subparsers, 'info', borg('info'))
    parse_wrapped_command(subparsers, 'mount', borg('mount'))
    parse_wrapped_command(subparsers, 'check', borg('check'))
    args = parser.parse_args(argv)
    return args
Пример #4
0
def create(config, section, archive_section):
    archive = config.get(section, 'borg.create.archive', fallback=None)
    if not archive:
        die('borg.create.archive was not specified in section', section)
    opts = list(
        extract_borg_commands_opts(config, 'create', section, [
            'dry-run', 'stats', 'list', 'json', 'no-cache-sync',
            'no-files-cache', 'exclude-caches', 'keep-exclude-tags',
            'keep-tag-files', 'exclude-nodump', 'one-file-system',
            'numeric-owner', 'noatime', 'noctime', 'nobirthtime', 'nobsdflags',
            'ignore-inode', 'read-special'
        ], [
            'e', 'exclude', 'exclude-from', 'pattern', 'patterns-from',
            'archive'
        ]))
    include = get_config_list(config, archive_section, 'include')
    exclude = get_config_list(config, archive_section, 'exclude')
    e_args = list(itertools.chain.from_iterable(('-e', e) for e in exclude))
    all_args = opts + e_args + ['::' + archive] + include
    log('running: borg create', *all_args)
    borg('create', *all_args)()
Пример #5
0
def rclone_sync(borg_repo, mirrors, check):
    for mirror in mirrors:
        if check:
            borg('check', '--verbose', '--progress', '--verify-data')()
        rclone('sync', '--ask-password=false', '-v', borg_repo, mirror)()
        log('synced {} to {}'.format(borg_repo, mirror))