Attempt to partly fix #18
This commit is contained in:
parent
a099060b2e
commit
c5b7f11db7
|
@ -5,6 +5,9 @@ services:
|
||||||
env_file:
|
env_file:
|
||||||
- restic_compose_backup.env
|
- restic_compose_backup.env
|
||||||
- alerts.env
|
- alerts.env
|
||||||
|
labels:
|
||||||
|
restic-compose-backup.volumes: true
|
||||||
|
restic-compose-backup.volumes.include: 'src'
|
||||||
volumes:
|
volumes:
|
||||||
# Map in docker socket
|
# Map in docker socket
|
||||||
- /var/run/docker.sock:/tmp/docker.sock:ro
|
- /var/run/docker.sock:/tmp/docker.sock:ro
|
||||||
|
|
|
@ -117,6 +117,7 @@ def backup(config, containers):
|
||||||
mounts = containers.generate_backup_mounts('/volumes')
|
mounts = containers.generate_backup_mounts('/volumes')
|
||||||
volumes.update(mounts)
|
volumes.update(mounts)
|
||||||
|
|
||||||
|
logger.debug('Starting backup container with image %s', containers.this_container.image)
|
||||||
try:
|
try:
|
||||||
result = backup_runner.run(
|
result = backup_runner.run(
|
||||||
image=containers.this_container.image,
|
image=containers.this_container.image,
|
||||||
|
@ -151,12 +152,18 @@ def backup(config, containers):
|
||||||
|
|
||||||
def start_backup_process(config, containers):
|
def start_backup_process(config, containers):
|
||||||
"""The actual backup process running inside the spawned container"""
|
"""The actual backup process running inside the spawned container"""
|
||||||
if (not containers.backup_process_container
|
if containers.this_container != containers.backup_process_container:
|
||||||
or containers.this_container == containers.backup_process_container is False):
|
|
||||||
logger.error(
|
logger.error(
|
||||||
"Cannot run backup process in this container. Use backup command instead. "
|
"Cannot run backup process in this container. Use backup command instead. "
|
||||||
"This will spawn a new container with the necessary mounts."
|
"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)
|
exit(1)
|
||||||
|
|
||||||
status(config, containers)
|
status(config, containers)
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
import os
|
import os
|
||||||
|
import logging
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
from restic_compose_backup import enums, utils
|
from restic_compose_backup import enums, utils
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
VOLUME_TYPE_BIND = "bind"
|
VOLUME_TYPE_BIND = "bind"
|
||||||
VOLUME_TYPE_VOLUME = "volume"
|
VOLUME_TYPE_VOLUME = "volume"
|
||||||
|
@ -355,7 +357,7 @@ class RunningContainers:
|
||||||
# Detect containers belonging to the current compose setup
|
# Detect containers belonging to the current compose setup
|
||||||
if (container.project_name == self.this_container.project_name
|
if (container.project_name == self.this_container.project_name
|
||||||
and not container.is_oneoff):
|
and not container.is_oneoff):
|
||||||
if container.id != self.this_container.id:
|
if container != self.backup_process_container:
|
||||||
self.containers.append(container)
|
self.containers.append(container)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
Loading…
Reference in New Issue