mirror of
https://github.com/ZettaIO/restic-compose-backup.git
synced 2025-12-16 02:31:07 +00:00
feat: add option to backup minecraft containers via rcon-cli
This commit is contained in:
committed by
Silthus
parent
47d1687bc1
commit
02ae4ca6d8
@@ -3,7 +3,7 @@ import logging
|
||||
from pathlib import Path
|
||||
from typing import List
|
||||
|
||||
from restic_compose_backup import enums, utils
|
||||
from restic_compose_backup import enums, utils, rcon
|
||||
from restic_compose_backup.config import config
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -46,6 +46,9 @@ class Container:
|
||||
return containers_db.MysqlContainer(self._data)
|
||||
if self.postgresql_backup_enabled:
|
||||
return containers_db.PostgresContainer(self._data)
|
||||
elif self.minecraft_backup_enabled:
|
||||
from restic_compose_backup import containers_minecraft
|
||||
return containers_minecraft.MinecraftContainer(self._data)
|
||||
else:
|
||||
return self
|
||||
|
||||
@@ -148,6 +151,11 @@ class Container:
|
||||
"""bool: If the ``restic-compose-backup.volumes`` label is set"""
|
||||
return utils.is_true(self.get_label(enums.LABEL_VOLUMES_ENABLED))
|
||||
|
||||
@property
|
||||
def minecraft_backup_enabled(self) -> bool:
|
||||
"""bool: If the ``restic-compose-backup.minecraft``` label is set"""
|
||||
return utils.is_true(self.get_label(enums.LABEL_MINECRAFT_ENABLED))
|
||||
|
||||
@property
|
||||
def database_backup_enabled(self) -> bool:
|
||||
"""bool: Is database backup enabled in any shape or form?"""
|
||||
@@ -428,6 +436,15 @@ class RunningContainers:
|
||||
|
||||
return mounts
|
||||
|
||||
def generate_minecraft_mounts(self, dest_prefix='/minecraft') -> dict:
|
||||
"""Generate minecraft mounts for backup for the entire compose setup"""
|
||||
mounts = {}
|
||||
for container in self.containers_for_backup():
|
||||
if container.minecraft_backup_enabled:
|
||||
mounts.update(container.volumes_for_backup(source_prefix=dest_prefix, mode='ro'))
|
||||
|
||||
return mounts
|
||||
|
||||
def get_service(self, name) -> Container:
|
||||
"""Container: Get a service by name"""
|
||||
for container in self.containers:
|
||||
|
||||
Reference in New Issue
Block a user