use latest snapshot as default

This commit is contained in:
Moritz 2023-09-07 02:03:11 +02:00
parent 28334a4241
commit 3009159c82
1 changed files with 5 additions and 4 deletions

View File

@ -10,7 +10,7 @@ import docker
import restic
from restic.errors import ResticFailedError
from pathlib import Path
logging.basicConfig(level=logging.INFO)
#logging.basicConfig(level=logging.INFO)
VOLUME_PATH = "/var/lib/docker/volumes/"
SERVICE = None
@ -100,10 +100,11 @@ def run_commands(commands):
def backup_volumes(backup_paths, apps, dry_run=False):
result = restic.backup(backup_paths, dry_run=dry_run, tags=apps)
print(result)
logging.info(result)
@cli.command()
@click.option('snapshot', '--snapshot', '-s', envvar='SNAPSHOT', required=True)
@click.option('snapshot', '--snapshot', '-s', envvar='SNAPSHOT', default='latest')
def restore(snapshot):
service_paths = f'/var/lib/docker/volumes/{SERVICE}_*'
result = restic.restore(snapshot_id=snapshot, include=service_paths, target_dir='/')
@ -117,7 +118,7 @@ def snapshots():
print(snap['time'], snap['id'])
@cli.command()
@click.option('snapshot', '--snapshot', '-s', envvar='SNAPSHOT', required=True)
@click.option('snapshot', '--snapshot', '-s', envvar='SNAPSHOT', default='latest')
@click.option('path', '--path', '-p', envvar='INCLUDE_PATH')
def ls(snapshot, path):
results = list_files(snapshot, path)
@ -135,7 +136,7 @@ def list_files(snapshot, path):
return results
@cli.command()
@click.option('snapshot', '--snapshot', '-s', envvar='SNAPSHOT', required=True)
@click.option('snapshot', '--snapshot', '-s', envvar='SNAPSHOT', default='latest')
@click.option('path', '--path', '-p', envvar='INCLUDE_PATH')
def download(snapshot, path):
files = list_files(snapshot, path)