choos specific restore target
This commit is contained in:
parent
203719c224
commit
5fa8f821c1
13
backupbot.py
13
backupbot.py
|
@ -4,7 +4,6 @@ import os
|
||||||
import click
|
import click
|
||||||
import json
|
import json
|
||||||
import subprocess
|
import subprocess
|
||||||
# todo json logging
|
|
||||||
import logging
|
import logging
|
||||||
import docker
|
import docker
|
||||||
import restic
|
import restic
|
||||||
|
@ -106,9 +105,15 @@ def backup_volumes(backup_paths, apps, dry_run=False):
|
||||||
|
|
||||||
@cli.command()
|
@cli.command()
|
||||||
@click.option('snapshot', '--snapshot', '-s', envvar='SNAPSHOT', default='latest')
|
@click.option('snapshot', '--snapshot', '-s', envvar='SNAPSHOT', default='latest')
|
||||||
def restore(snapshot):
|
@click.option('target', '--target', '-t', envvar='TARGET', default='/')
|
||||||
service_paths = f'/var/lib/docker/volumes/{SERVICE}_*'
|
def restore(snapshot, target):
|
||||||
result = restic.restore(snapshot_id=snapshot, include=service_paths, target_dir='/')
|
# 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()
|
@cli.command()
|
||||||
|
|
|
@ -21,7 +21,7 @@ services:
|
||||||
target: /entrypoint.sh
|
target: /entrypoint.sh
|
||||||
mode: 0555
|
mode: 0555
|
||||||
- source: backupbot
|
- source: backupbot
|
||||||
target: /backup
|
target: /usr/bin/backup
|
||||||
mode: 0555
|
mode: 0555
|
||||||
entrypoint: ['/entrypoint.sh']
|
entrypoint: ['/entrypoint.sh']
|
||||||
|
|
||||||
|
|
|
@ -2,14 +2,14 @@
|
||||||
|
|
||||||
set -eu
|
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
|
pip install click docker resticpy
|
||||||
|
|
||||||
cron_schedule="${CRON_SCHEDULE:?CRON_SCHEDULE not set}"
|
cron_schedule="${CRON_SCHEDULE:?CRON_SCHEDULE not set}"
|
||||||
|
|
||||||
#echo "$cron_schedule /backupbot.py" | crontab -
|
echo "$cron_schedule backup create" | crontab -
|
||||||
crontab -l
|
crontab -l
|
||||||
|
|
||||||
crond -f -d8 -L /dev/stdout
|
crond -f -d8 -L /dev/stdout
|
||||||
|
|
Loading…
Reference in New Issue