def test_prune_archives_should_call_borg_with_parameters(): retention_config = flexmock() flexmock(module).should_receive('_make_prune_flags').with_args( retention_config).and_return(BASE_PRUNE_FLAGS, ) insert_subprocess_mock(PRUNE_COMMAND) module.prune_archives( verbosity=None, repository='repo', retention_config=retention_config, command='borg', )
def test_prune_archives_with_verbosity_lots_should_call_borg_with_debug_parameter( ): retention_config = flexmock() flexmock(module).should_receive('_make_prune_flags').with_args( retention_config).and_return(BASE_PRUNE_FLAGS, ) insert_subprocess_mock(PRUNE_COMMAND + ( '--debug', '--stats', )) module.prune_archives( repository='repo', verbosity=VERBOSITY_LOTS, retention_config=retention_config, command='borg', )
def main(): try: args = parse_arguments(*sys.argv[1:]) config = parse_configuration(args.config_filename, CONFIG_FORMAT) repository = config.location['repository'] remote_path = config.location.get('remote_path') borg.initialize(config.storage) borg.create_archive(args.excludes_filename, args.verbosity, config.storage, **config.location) borg.prune_archives(args.verbosity, repository, config.retention, remote_path=remote_path) borg.check_archives(args.verbosity, repository, config.consistency, remote_path=remote_path) except (ValueError, IOError, CalledProcessError) as error: print(error, file=sys.stderr) sys.exit(1)