choos specific restore target

This commit is contained in:
Moritz 2023-09-07 13:10:10 +02:00
parent 203719c224
commit 5fa8f821c1
3 changed files with 13 additions and 8 deletions

View File

@ -4,7 +4,6 @@ import os
import click
import json
import subprocess
# todo json logging
import logging
import docker
import restic
@ -106,9 +105,15 @@ def backup_volumes(backup_paths, apps, dry_run=False):
@cli.command()
@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='/')
@click.option('target', '--target', '-t', envvar='TARGET', default='/')
def restore(snapshot, target):
# Todo: recommend to shutdown the container
service_paths = VOLUME_PATH
if SERVICE:
service_paths = service_paths + f'{SERVICE}_*'
print(f"restoring Snapshot {snapshot} of {service_paths} at {target}")
result = restic.restore(snapshot_id=snapshot, include=service_paths, target_dir=target)
logging.debug(result)
@cli.command()

View File

@ -21,7 +21,7 @@ services:
target: /entrypoint.sh
mode: 0555
- source: backupbot
target: /backup
target: /usr/bin/backup
mode: 0555
entrypoint: ['/entrypoint.sh']

View File

@ -2,14 +2,14 @@
set -eu
apk add --upgrade --no-cache bash curl jq restic python3 py3-pip
apk add --upgrade --no-cache bash restic python3 py3-pip
# Todo use requirements file
# Todo use requirements file with specific versions
pip install click docker resticpy
cron_schedule="${CRON_SCHEDULE:?CRON_SCHEDULE not set}"
#echo "$cron_schedule /backupbot.py" | crontab -
echo "$cron_schedule backup create" | crontab -
crontab -l
crond -f -d8 -L /dev/stdout