rcb snapshots
This commit is contained in:
parent
f8a9f0e7e9
commit
f288f77aa4
|
@ -23,6 +23,9 @@ def main():
|
||||||
if args.action == 'status':
|
if args.action == 'status':
|
||||||
status(config, containers)
|
status(config, containers)
|
||||||
|
|
||||||
|
if args.action == 'snapshots':
|
||||||
|
snapshots(config, containers)
|
||||||
|
|
||||||
elif args.action == 'backup':
|
elif args.action == 'backup':
|
||||||
backup(config, containers)
|
backup(config, containers)
|
||||||
|
|
||||||
|
@ -56,6 +59,12 @@ def status(config, containers):
|
||||||
|
|
||||||
logger.info("-" * 67)
|
logger.info("-" * 67)
|
||||||
|
|
||||||
|
def snapshots(config, containers):
|
||||||
|
"""Display restic snapshots"""
|
||||||
|
stdout, stderr = restic.snapshots(config.repository)
|
||||||
|
for line in stdout.decode().split('\n'):
|
||||||
|
logger.info('| %s', line)
|
||||||
|
|
||||||
|
|
||||||
def backup(config, containers):
|
def backup(config, containers):
|
||||||
"""Request a backup to start"""
|
"""Request a backup to start"""
|
||||||
|
@ -134,7 +143,7 @@ def parse_args():
|
||||||
parser = argparse.ArgumentParser(prog='restic_compose_backup')
|
parser = argparse.ArgumentParser(prog='restic_compose_backup')
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'action',
|
'action',
|
||||||
choices=['status', 'backup', 'start-backup-process'],
|
choices=['status', 'snapshots', 'backup', 'start-backup-process'],
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--log-level',
|
'--log-level',
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Restic commands
|
Restic commands
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
from typing import List
|
from typing import List, Tuple
|
||||||
from subprocess import Popen, PIPE
|
from subprocess import Popen, PIPE
|
||||||
from restic_compose_backup import commands
|
from restic_compose_backup import commands
|
||||||
|
|
||||||
|
@ -57,8 +57,8 @@ def backup_from_stdin(repository: str, filename: str, source_command: List[str])
|
||||||
return 0 if (source_exit == 0 and dest_exit == 0) else 1
|
return 0 if (source_exit == 0 and dest_exit == 0) else 1
|
||||||
|
|
||||||
|
|
||||||
def snapshots(repository: str):
|
def snapshots(repository: str) -> Tuple[str, str]:
|
||||||
return commands.run(restic(repository, [
|
return commands.run_capture_std(restic(repository, [
|
||||||
"snapshots",
|
"snapshots",
|
||||||
]))
|
]))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue