Attempt to partly fix #18

This commit is contained in:
Einar Forselv 2019-12-10 07:57:37 +01:00
parent a099060b2e
commit c5b7f11db7
3 changed files with 15 additions and 3 deletions

View File

@ -5,6 +5,9 @@ services:
env_file:
- restic_compose_backup.env
- alerts.env
labels:
restic-compose-backup.volumes: true
restic-compose-backup.volumes.include: 'src'
volumes:
# Map in docker socket
- /var/run/docker.sock:/tmp/docker.sock:ro

View File

@ -117,6 +117,7 @@ def backup(config, containers):
mounts = containers.generate_backup_mounts('/volumes')
volumes.update(mounts)
logger.debug('Starting backup container with image %s', containers.this_container.image)
try:
result = backup_runner.run(
image=containers.this_container.image,
@ -151,12 +152,18 @@ def backup(config, containers):
def start_backup_process(config, containers):
"""The actual backup process running inside the spawned container"""
if (not containers.backup_process_container
or containers.this_container == containers.backup_process_container is False):
if containers.this_container != containers.backup_process_container:
logger.error(
"Cannot run backup process in this container. Use backup command instead. "
"This will spawn a new container with the necessary mounts."
)
alerts.send(
subject="Cannot run backup process in this container",
body=(
"Cannot run backup process in this container. Use backup command instead. "
"This will spawn a new container with the necessary mounts."
)
)
exit(1)
status(config, containers)

View File

@ -1,9 +1,11 @@
import os
import logging
from pathlib import Path
from typing import List
from restic_compose_backup import enums, utils
logger = logging.getLogger(__name__)
VOLUME_TYPE_BIND = "bind"
VOLUME_TYPE_VOLUME = "volume"
@ -355,7 +357,7 @@ class RunningContainers:
# Detect containers belonging to the current compose setup
if (container.project_name == self.this_container.project_name
and not container.is_oneoff):
if container.id != self.this_container.id:
if container != self.backup_process_container:
self.containers.append(container)
@property