use latest snapshot as default
This commit is contained in:
parent
28334a4241
commit
3009159c82
|
@ -10,7 +10,7 @@ import docker
|
||||||
import restic
|
import restic
|
||||||
from restic.errors import ResticFailedError
|
from restic.errors import ResticFailedError
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
logging.basicConfig(level=logging.INFO)
|
#logging.basicConfig(level=logging.INFO)
|
||||||
|
|
||||||
VOLUME_PATH = "/var/lib/docker/volumes/"
|
VOLUME_PATH = "/var/lib/docker/volumes/"
|
||||||
SERVICE = None
|
SERVICE = None
|
||||||
|
@ -100,10 +100,11 @@ def run_commands(commands):
|
||||||
|
|
||||||
def backup_volumes(backup_paths, apps, dry_run=False):
|
def backup_volumes(backup_paths, apps, dry_run=False):
|
||||||
result = restic.backup(backup_paths, dry_run=dry_run, tags=apps)
|
result = restic.backup(backup_paths, dry_run=dry_run, tags=apps)
|
||||||
|
print(result)
|
||||||
logging.info(result)
|
logging.info(result)
|
||||||
|
|
||||||
@cli.command()
|
@cli.command()
|
||||||
@click.option('snapshot', '--snapshot', '-s', envvar='SNAPSHOT', required=True)
|
@click.option('snapshot', '--snapshot', '-s', envvar='SNAPSHOT', default='latest')
|
||||||
def restore(snapshot):
|
def restore(snapshot):
|
||||||
service_paths = f'/var/lib/docker/volumes/{SERVICE}_*'
|
service_paths = f'/var/lib/docker/volumes/{SERVICE}_*'
|
||||||
result = restic.restore(snapshot_id=snapshot, include=service_paths, target_dir='/')
|
result = restic.restore(snapshot_id=snapshot, include=service_paths, target_dir='/')
|
||||||
|
@ -117,7 +118,7 @@ def snapshots():
|
||||||
print(snap['time'], snap['id'])
|
print(snap['time'], snap['id'])
|
||||||
|
|
||||||
@cli.command()
|
@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')
|
@click.option('path', '--path', '-p', envvar='INCLUDE_PATH')
|
||||||
def ls(snapshot, path):
|
def ls(snapshot, path):
|
||||||
results = list_files(snapshot, path)
|
results = list_files(snapshot, path)
|
||||||
|
@ -135,7 +136,7 @@ def list_files(snapshot, path):
|
||||||
return results
|
return results
|
||||||
|
|
||||||
@cli.command()
|
@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')
|
@click.option('path', '--path', '-p', envvar='INCLUDE_PATH')
|
||||||
def download(snapshot, path):
|
def download(snapshot, path):
|
||||||
files = list_files(snapshot, path)
|
files = list_files(snapshot, path)
|
||||||
|
|
Loading…
Reference in New Issue