forked from coop-cloud/backup-bot-two
Compare commits
8 Commits
feature/do
...
feature/se
Author | SHA1 | Date | |
---|---|---|---|
d998b61117 | |||
c93d5c6f44 | |||
52e52a1e1d | |||
771cf31824 | |||
83834c6570 | |||
98b5f077e2 | |||
ed687e52c3 | |||
cf06532da9 |
2
abra.sh
2
abra.sh
@ -1,3 +1,3 @@
|
|||||||
export ENTRYPOINT_VERSION=v1
|
export ENTRYPOINT_VERSION=v2
|
||||||
export BACKUPBOT_VERSION=v1
|
export BACKUPBOT_VERSION=v1
|
||||||
export SSH_CONFIG_VERSION=v1
|
export SSH_CONFIG_VERSION=v1
|
||||||
|
11
backupbot.py
11
backupbot.py
@ -85,6 +85,7 @@ def get_backup_cmds():
|
|||||||
services = client.services.list()
|
services = client.services.list()
|
||||||
for s in services:
|
for s in services:
|
||||||
labels = s.attrs['Spec']['Labels']
|
labels = s.attrs['Spec']['Labels']
|
||||||
|
mounts = s.attrs['Spec']['TaskTemplate']['ContainerSpec']['Mounts']
|
||||||
if (backup := labels.get('backupbot.backup')) and bool(backup):
|
if (backup := labels.get('backupbot.backup')) and bool(backup):
|
||||||
stack_name = labels['com.docker.stack.namespace']
|
stack_name = labels['com.docker.stack.namespace']
|
||||||
# Remove this lines to backup only a specific service
|
# Remove this lines to backup only a specific service
|
||||||
@ -92,8 +93,14 @@ def get_backup_cmds():
|
|||||||
# if SERVICE and SERVICE != stack_name:
|
# if SERVICE and SERVICE != stack_name:
|
||||||
# continue
|
# continue
|
||||||
backup_apps.add(stack_name)
|
backup_apps.add(stack_name)
|
||||||
backup_paths = backup_paths.union(
|
for mount in mounts:
|
||||||
Path(VOLUME_PATH).glob(f"{stack_name}_*"))
|
if path := labels.get('backupbot.backup.path'):
|
||||||
|
path_ = Path(VOLUME_PATH) / f"{mount['Source']}/_data/{path}"
|
||||||
|
else:
|
||||||
|
path_ = Path(VOLUME_PATH) / f"{mount['Source']}"
|
||||||
|
logging.debug(
|
||||||
|
f"Added backup path {path_}")
|
||||||
|
backup_paths.add(path_)
|
||||||
if not (container := container_by_service.get(s.name)):
|
if not (container := container_by_service.get(s.name)):
|
||||||
logging.error(
|
logging.error(
|
||||||
f"Container {s.name} is not running, hooks can not be executed")
|
f"Container {s.name} is not running, hooks can not be executed")
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
version: "3.8"
|
version: "3.8"
|
||||||
services:
|
services:
|
||||||
app:
|
app:
|
||||||
image: git.coopcloud.tech/coop-cloud:2.0.0
|
image: git.coopcloud.tech/coop-cloud/backup-bot-two:2.0.0
|
||||||
volumes:
|
volumes:
|
||||||
- "/var/run/docker.sock:/var/run/docker.sock"
|
- "/var/run/docker.sock:/var/run/docker.sock"
|
||||||
- "/var/lib/docker/volumes/:/var/lib/docker/volumes/"
|
- "/var/lib/docker/volumes/:/var/lib/docker/volumes/"
|
||||||
|
@ -2,11 +2,6 @@
|
|||||||
|
|
||||||
set -e -o pipefail
|
set -e -o pipefail
|
||||||
|
|
||||||
apk add --upgrade --no-cache restic bash python3 py3-pip
|
|
||||||
|
|
||||||
# Todo use requirements file with specific versions
|
|
||||||
pip install click==8.1.7 docker==6.1.3 resticpy==1.0.2
|
|
||||||
|
|
||||||
if [ -n "$SSH_HOST_KEY" ]
|
if [ -n "$SSH_HOST_KEY" ]
|
||||||
then
|
then
|
||||||
echo "$SSH_HOST_KEY" > /root/.ssh/known_hosts
|
echo "$SSH_HOST_KEY" > /root/.ssh/known_hosts
|
||||||
|
Reference in New Issue
Block a user