mirror of
https://github.com/netinvent/npbackup.git
synced 2025-11-08 13:11:50 +08:00
CLI: Added --no-cache option
This commit is contained in:
parent
61d5e5c64c
commit
729a2a7c1f
6 changed files with 41 additions and 6 deletions
|
|
@ -40,6 +40,7 @@
|
|||
- Metrics have npbackup execution state
|
||||
- Dry mode now works for all operations where restic supports dry-mode
|
||||
- Implemented scheduled task creator for Windows & Unix
|
||||
- Added --no-cache option to disable cache for restic operations
|
||||
|
||||
## Fixes
|
||||
- Default exit code is now worst log level called unless specific errors are triggered
|
||||
|
|
|
|||
|
|
@ -226,6 +226,11 @@ This is free software, and you are welcome to redistribute it under certain cond
|
|||
action="store_true",
|
||||
help="Run operations in test mode, no actual modifications",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--no-cache",
|
||||
action="store_true",
|
||||
help="Run operations without cache",
|
||||
)
|
||||
|
||||
parser.add_argument("--license", action="store_true", help="Show license")
|
||||
parser.add_argument(
|
||||
|
|
@ -444,6 +449,7 @@ This is free software, and you are welcome to redistribute it under certain cond
|
|||
"dry_run": args.dry_run,
|
||||
"json_output": args.json,
|
||||
"backend_binary": backend_binary,
|
||||
"no_cache": args.no_cache,
|
||||
"operation": None,
|
||||
"op_args": {},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ __site__ = "https://www.netperfect.fr/npbackup"
|
|||
__description__ = "NetPerfect Backup Client"
|
||||
__copyright__ = "Copyright (C) 2022-2024 NetInvent"
|
||||
__license__ = "GPL-3.0-only"
|
||||
__build__ = "2024060501"
|
||||
__version__ = "3.0.0-rc1-4"
|
||||
__build__ = "2024061101"
|
||||
__version__ = "3.0.0-rc1+dev"
|
||||
|
||||
|
||||
import sys
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ __intname__ = "npbackup.gui.core.runner"
|
|||
__author__ = "Orsiris de Jong"
|
||||
__copyright__ = "Copyright (C) 2022-2024 NetInvent"
|
||||
__license__ = "GPL-3.0-only"
|
||||
__build__ = "2024050901"
|
||||
__build__ = "2024061101"
|
||||
|
||||
|
||||
from typing import Optional, Callable, Union, List
|
||||
|
|
@ -203,6 +203,7 @@ class NPBackupRunner:
|
|||
self._live_output = False
|
||||
self._json_output = False
|
||||
self._binary = None
|
||||
self._no_cache = False
|
||||
self.restic_runner = None
|
||||
self.minimum_backup_age = None
|
||||
self._exec_time = None
|
||||
|
|
@ -237,6 +238,17 @@ class NPBackupRunner:
|
|||
self.write_logs(msg, level="critical", raise_error="ValueError")
|
||||
self._dry_run = value
|
||||
|
||||
@property
|
||||
def no_cache(self):
|
||||
return self._no_cache
|
||||
|
||||
@no_cache.setter
|
||||
def no_cache(self, value):
|
||||
if not isinstance(value, bool):
|
||||
msg = f"Bogus no_cache parameter given: {value}"
|
||||
self.write_logs(msg, level="critical", raise_error="ValueError")
|
||||
self._no_cache = value
|
||||
|
||||
@property
|
||||
def verbose(self):
|
||||
return self._verbose
|
||||
|
|
@ -786,6 +798,7 @@ class NPBackupRunner:
|
|||
|
||||
self.restic_runner.verbose = self.verbose
|
||||
self.restic_runner.dry_run = self.dry_run
|
||||
self.restic_runner.no_cache = self.no_cache
|
||||
self.restic_runner.live_output = self.live_output
|
||||
self.restic_runner.json_output = self.json_output
|
||||
self.restic_runner.stdout = self.stdout
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ __intname__ = "npbackup.restic_wrapper"
|
|||
__author__ = "Orsiris de Jong"
|
||||
__copyright__ = "Copyright (C) 2022-2024 NetInvent"
|
||||
__license__ = "GPL-3.0-only"
|
||||
__build__ = "2024052501"
|
||||
__version__ = "2.1.0"
|
||||
__build__ = "2024060101"
|
||||
__version__ = "2.2.0"
|
||||
|
||||
|
||||
from typing import Tuple, List, Optional, Callable, Union
|
||||
|
|
@ -45,6 +45,7 @@ class ResticRunner:
|
|||
self._verbose = False
|
||||
self._live_output = False
|
||||
self._dry_run = False
|
||||
self._no_cache = False
|
||||
self._json_output = False
|
||||
|
||||
self.backup_result_content = None
|
||||
|
|
@ -194,7 +195,18 @@ class ResticRunner:
|
|||
if isinstance(value, bool):
|
||||
self._dry_run = value
|
||||
else:
|
||||
raise ValueError("Bogus dry run value given")
|
||||
raise ValueError("Bogus dry_run value given")
|
||||
|
||||
@property
|
||||
def no_cache(self) -> bool:
|
||||
return self._no_cache
|
||||
|
||||
@no_cache.setter
|
||||
def no_cache(self, value: bool):
|
||||
if isinstance(value, bool):
|
||||
self._no_cache = value
|
||||
else:
|
||||
raise ValueError("Bogus no_cache value given")
|
||||
|
||||
@property
|
||||
def json_output(self) -> bool:
|
||||
|
|
@ -508,6 +520,8 @@ class ResticRunner:
|
|||
args += " --dry-run"
|
||||
if self.json_output:
|
||||
args += " --json"
|
||||
if self.no_cache:
|
||||
args += " --no-cache"
|
||||
return args
|
||||
|
||||
def init(
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ def entrypoint(*args, **kwargs):
|
|||
npbackup_runner.verbose = kwargs.pop("verbose")
|
||||
npbackup_runner.live_output = not json_output
|
||||
npbackup_runner.json_output = json_output
|
||||
npbackup_runner.no_cache = kwargs.pop("no_cache", False)
|
||||
if backend_binary:
|
||||
npbackup_runner.binary = backend_binary
|
||||
result = npbackup_runner.__getattribute__(operation)(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue