Example #1
0
def run(restic_base_command, mode=None):
    cmd = restic_base_command + ['stats']

    if mode:
        cmd.extend(['--mode', mode])

    return json.loads(command_executor.execute(cmd))
Example #2
0
def run(restic_base_command, snapshot_id='latest', target_dir=None):
    cmd = restic_base_command + ['restore', snapshot_id]

    if target_dir:
        cmd.extend(['--target', target_dir])

    return command_executor.execute(cmd)
Example #3
0
def run(restic_base_command, group_by=None):
    cmd = restic_base_command + ['snapshots']

    if group_by:
        cmd.extend(['--group-by', group_by])

    return json.loads(command_executor.execute(cmd))
Example #4
0
def run(restic_base_command, repo2=None, password_file2=None):
    cmd = restic_base_command + ['copy']

    if repo2:
        cmd.extend(['--repo2', repo2])

    if password_file2:
        cmd.extend(['--password-file2', password_file2])

    return command_executor.execute(cmd)
Example #5
0
def run(restic_base_command, read_data=False):
    cmd = restic_base_command + ['check']

    if read_data:
        cmd.append('--read-data')

    try:
        return command_executor.execute(cmd)
    except restic.errors.ResticFailedError:
        return None
Example #6
0
def run(restic_base_command, copy_chunker_params=False, repo2=None):
    cmd = restic_base_command + ['init']

    if copy_chunker_params:
        cmd.append('--copy-chunker-params')

    if repo2:
        cmd.extend(['--repo2', repo2])

    return _parse_result(command_executor.execute(cmd))
Example #7
0
def run(restic_base_command):
    cmd = restic_base_command + ['version']
    out = command_executor.execute(cmd)
    match = re.match((r'restic ([0-9\.]+) compiled with go([0-9\.]+) '
                      'on ([a-zA-Z0-9]+)/([a-zA-Z0-9]+)'), out)
    return {
        'restic_version': match.group(1),
        'go_version': match.group(2),
        'platform_version': match.group(3),
        'architecture': match.group(4)
    }
Example #8
0
def run(restic_base_command, paths, exclude_patterns=None, exclude_files=None):
    cmd = restic_base_command + ['backup'] + paths

    if exclude_patterns:
        for exclude_pattern in exclude_patterns:
            cmd.extend(['--exclude', exclude_pattern])

    if exclude_files:
        for exclude_file in exclude_files:
            cmd.extend(['--exclude-file', exclude_file])

    result_raw = command_executor.execute(cmd)
    return _parse_result(result_raw)
Example #9
0
def run(restic_base_command,
        bash_completion_path=None,
        man_directory=None,
        zsh_completion_path=None):
    cmd = restic_base_command + ['generate']

    if bash_completion_path is not None:
        cmd.extend(['--bash-completion', bash_completion_path])

    if man_directory is not None:
        cmd.extend(['--man', man_directory])

    if zsh_completion_path is not None:
        cmd.extend(['--zsh-completion', zsh_completion_path])

    return command_executor.execute(cmd)
Example #10
0
def run(restic_base_command,
        prune=False,
        keep_daily=None,
        keep_within=None,
        group_by=None):
    cmd = restic_base_command + ['forget']

    if prune:
        cmd.extend(['--prune'])

    if keep_daily is not None:
        cmd.extend(['--keep-daily', str(keep_daily)])

    if keep_within is not None:
        cmd.extend(['--keep-within', keep_within])

    if group_by is not None:
        cmd.extend(['--group-by', group_by])

    return _parse_result(command_executor.execute(cmd))
Example #11
0
def run(restic_base_command):
    cmd = restic_base_command + ['self-update']
    return command_executor.execute(cmd)
Example #12
0
def run(restic_base_command):
    cmd = restic_base_command + ['unlock']

    return command_executor.execute(cmd)