mirror of
https://github.com/kevinveenbirkenbach/docker-volume-backup.git
synced 2026-07-17 14:15:13 +00:00
feat(backup)!: exact --images-* matching and --hard-restart-projects
Match --images-no-stop-required and --images-no-backup-required against the container's exact .Config.Image instead of a substring, so callers pass full repo:tag references (registry prefix included) and near-miss image names no longer flip the stop/skip decision. Rename the opt-in --hard-compose-restart flag to --hard-restart-projects. The e2e suite pins a SPOT for the DB images and in-container data dirs (postgres:alpine at /var/lib/postgresql, mariadb:latest at /var/lib/mysql) and passes exact image refs to the --images-* flags. BREAKING CHANGE: --images-* now require exact image references, not substrings; --hard-compose-restart is renamed to --hard-restart-projects. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -52,7 +52,7 @@ def is_image_ignored(container: str, images_no_backup_required: list[str]) -> bo
|
||||
if not images_no_backup_required:
|
||||
return False
|
||||
img = get_image_info(container)
|
||||
return any(pat in img for pat in images_no_backup_required)
|
||||
return img in images_no_backup_required
|
||||
|
||||
|
||||
def volume_is_fully_ignored(
|
||||
@@ -68,15 +68,15 @@ def volume_is_fully_ignored(
|
||||
|
||||
def requires_stop(containers: list[str], images_no_stop_required: list[str]) -> bool:
|
||||
"""
|
||||
Stop is required if ANY stoppable container image is NOT in the
|
||||
whitelist patterns. Swarm task containers never count: baudolo must
|
||||
Stop is required if ANY stoppable container image is NOT in the exact
|
||||
image whitelist. Swarm task containers never count: baudolo must
|
||||
not cycle them (see docker.is_swarm_task).
|
||||
"""
|
||||
for c in containers:
|
||||
if is_swarm_task(c):
|
||||
continue
|
||||
img = get_image_info(c)
|
||||
if not any(pat in img for pat in images_no_stop_required):
|
||||
if img not in images_no_stop_required:
|
||||
return True
|
||||
return False
|
||||
|
||||
@@ -247,6 +247,6 @@ def main() -> int:
|
||||
print("Finished volume backups.", flush=True)
|
||||
|
||||
print("Handling Docker Compose services...", flush=True)
|
||||
handle_docker_compose_services(args.compose_dir, args.hard_compose_restart)
|
||||
handle_docker_compose_services(args.compose_dir, args.hard_restart_projects)
|
||||
|
||||
return 0
|
||||
|
||||
@@ -17,7 +17,7 @@ def parse_args() -> argparse.Namespace:
|
||||
help="Path to the parent directory containing docker-compose setups",
|
||||
)
|
||||
p.add_argument(
|
||||
"--hard-compose-restart",
|
||||
"--hard-restart-projects",
|
||||
nargs="*",
|
||||
default=[],
|
||||
help="Compose dir names that require 'docker-compose down && up -d' (default: none; pass e.g. 'mailu' under compose where the DB cannot be backed up hot)",
|
||||
@@ -49,13 +49,13 @@ def parse_args() -> argparse.Namespace:
|
||||
"--images-no-stop-required",
|
||||
nargs="+",
|
||||
required=True,
|
||||
help="Image name patterns for which containers should not be stopped during file backup",
|
||||
help="Exact image references (repo:tag, incl. any registry prefix) whose containers must not be stopped during file backup",
|
||||
)
|
||||
p.add_argument(
|
||||
"--images-no-backup-required",
|
||||
nargs="+",
|
||||
default=[],
|
||||
help="Image name patterns for which no backup should be performed",
|
||||
help="Exact image references (repo:tag, incl. any registry prefix) for which no backup should be performed",
|
||||
)
|
||||
|
||||
p.add_argument(
|
||||
|
||||
Reference in New Issue
Block a user