mirror of
https://github.com/ZettaIO/restic-compose-backup.git
synced 2025-12-15 02:01:08 +00:00
Detect if a repository should be initialized
This is better than trying to initialize it every time
This commit is contained in:
@@ -58,12 +58,23 @@ def backup_from_stdin(repository: str, filename: str, source_command: List[str])
|
||||
|
||||
|
||||
def snapshots(repository: str, last=True) -> Tuple[str, str]:
|
||||
"""Returns the stdout and stderr info"""
|
||||
args = ["snapshots"]
|
||||
if last:
|
||||
args.append('--last')
|
||||
return commands.run_capture_std(restic(repository, args))
|
||||
|
||||
|
||||
def is_initialized(repository: str) -> bool:
|
||||
"""
|
||||
Checks if a repository is initialized using snapshots command.
|
||||
Note that this cannot separate between uninitalized repo
|
||||
and other errors, but this method is reccomended by the restic
|
||||
community.
|
||||
"""
|
||||
return commands.run(restic(repository, ["snapshots", '--last'])) == 0
|
||||
|
||||
|
||||
def forget(repository: str, daily: str, weekly: str, monthly: str, yearly: str):
|
||||
return commands.run(restic(repository, [
|
||||
'forget',
|
||||
|
||||
Reference in New Issue
Block a user