Beispiel #1
0
def runrestic() -> None:
    if not restic_check():
        return

    args, extras = cli_arguments()
    configure_logging(args.log_level)
    configure_signals()

    if args.config_file:
        config_file_paths = [args.config_file]
    else:
        config_file_paths = list(configuration_file_paths())

        if not len(config_file_paths):
            raise FileNotFoundError(
                f"Error: No configuration files found in {possible_config_paths()}"
            )

    configs: List[Dict[str, Any]] = []
    for c in config_file_paths:
        parsed_cfg = parse_configuration(c)
        if parsed_cfg:
            configs += [parsed_cfg]

    if "shell" in args.actions:
        restic_shell(configs)
        return

    for config in configs:
        runner = ResticRunner(config, args, extras)
        runner.run()
Beispiel #2
0
def test_parse_configuration_good_conf(restic_minimal_good_conf):
    assert parse_configuration(restic_minimal_good_conf) == {
        "name": "example.toml",
        "repositories": ["/tmp/restic-repo-1"],
        "environment": {"RESTIC_PASSWORD": "******"},
        "execution": {"exit_on_error": True, "parallel": False, "retry_count": 0},
        "backup": {"sources": ["/etc"]},
        "prune": {"keep-last": 10},
    }
def test_parse_configuration_broken_conf(caplog, restic_minimal_broken_conf):
    with pytest.raises(TomlDecodeError):
        parse_configuration(restic_minimal_broken_conf)
Beispiel #4
0
def test_parse_configuration_broken_conf(caplog, restic_minimal_broken_conf):
    config = parse_configuration(restic_minimal_broken_conf)
    assert config is None
    assert f"Problem parsing {restic_minimal_broken_conf}" in caplog.text