diff --git a/npbackup/configuration.py b/npbackup/configuration.py index 548e49f..af203c5 100644 --- a/npbackup/configuration.py +++ b/npbackup/configuration.py @@ -164,7 +164,7 @@ empty_config_dict = { "exclude_files_larger_than": None, "additional_parameters": None, "additional_backup_only_parameters": None, - "minimum_backup_size_error": "10", # In megabytes + "minimum_backup_size_error": "10MiB", # allows BytesConverter units "pre_exec_commands": [], "pre_exec_per_command_timeout": 3600, "pre_exec_failure_is_fatal": False, diff --git a/npbackup/restic_metrics/__init__.py b/npbackup/restic_metrics/__init__.py index 3721195..e7fc6cc 100644 --- a/npbackup/restic_metrics/__init__.py +++ b/npbackup/restic_metrics/__init__.py @@ -168,7 +168,7 @@ def restic_str_output_to_json( def restic_json_to_prometheus( - restic_result: bool, restic_json: dict, labels: dict = None, minimum_backup_size_error: float = None, + restic_result: bool, restic_json: dict, labels: dict = None, minimum_backup_size_error: str = None, ) -> Tuple[bool, List[str], bool]: """ Transform a restic JSON result into prometheus metrics @@ -225,7 +225,7 @@ def restic_json_to_prometheus( backup_too_small = False if minimum_backup_size_error: - if restic_json["data_added"] < minimum_backup_size_error: + if restic_json["data_added"] < int(BytesConverter(str(minimum_backup_size_error).replace(" ", ""))): backup_too_small = True good_backup = restic_result and not backup_too_small