rcb snapshots

This commit is contained in:
Einar Forselv 2019-12-04 03:12:36 +01:00
parent f8a9f0e7e9
commit f288f77aa4
2 changed files with 13 additions and 4 deletions

View File

@ -23,6 +23,9 @@ def main():
if args.action == 'status':
status(config, containers)
if args.action == 'snapshots':
snapshots(config, containers)
elif args.action == 'backup':
backup(config, containers)
@ -56,6 +59,12 @@ def status(config, containers):
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):
"""Request a backup to start"""
@ -134,7 +143,7 @@ def parse_args():
parser = argparse.ArgumentParser(prog='restic_compose_backup')
parser.add_argument(
'action',
choices=['status', 'backup', 'start-backup-process'],
choices=['status', 'snapshots', 'backup', 'start-backup-process'],
)
parser.add_argument(
'--log-level',

View File

@ -2,7 +2,7 @@
Restic commands
"""
import logging
from typing import List
from typing import List, Tuple
from subprocess import Popen, PIPE
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
def snapshots(repository: str):
return commands.run(restic(repository, [
def snapshots(repository: str) -> Tuple[str, str]:
return commands.run_capture_std(restic(repository, [
"snapshots",
]))