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>
83 lines
2.5 KiB
Python
83 lines
2.5 KiB
Python
from __future__ import annotations
|
|
|
|
import argparse
|
|
import os
|
|
|
|
|
|
def parse_args() -> argparse.Namespace:
|
|
dirname = os.path.dirname(__file__)
|
|
default_databases_csv = os.path.join(dirname, "databases.csv")
|
|
|
|
p = argparse.ArgumentParser(description="Backup Docker volumes.")
|
|
|
|
p.add_argument(
|
|
"--compose-dir",
|
|
type=str,
|
|
required=True,
|
|
help="Path to the parent directory containing docker-compose setups",
|
|
)
|
|
p.add_argument(
|
|
"--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)",
|
|
)
|
|
|
|
p.add_argument(
|
|
"--repo-name",
|
|
default="backup-docker-to-local",
|
|
help="Backup repo folder name under <backups-dir>/<machine-id>/ (default: git repo folder name)",
|
|
)
|
|
p.add_argument(
|
|
"--databases-csv",
|
|
default=default_databases_csv,
|
|
help=f"Path to databases.csv (default: {default_databases_csv})",
|
|
)
|
|
p.add_argument(
|
|
"--backups-dir",
|
|
required=True,
|
|
help="Backup root directory (e.g. /var/lib/backup/)",
|
|
)
|
|
|
|
p.add_argument(
|
|
"--database-containers",
|
|
nargs="+",
|
|
required=True,
|
|
help="Container names treated as special instances for database backups",
|
|
)
|
|
p.add_argument(
|
|
"--images-no-stop-required",
|
|
nargs="+",
|
|
required=True,
|
|
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="Exact image references (repo:tag, incl. any registry prefix) for which no backup should be performed",
|
|
)
|
|
|
|
p.add_argument(
|
|
"--everything",
|
|
action="store_true",
|
|
help="Force file backup for all volumes and also execute database dumps (like old script)",
|
|
)
|
|
p.add_argument(
|
|
"--shutdown",
|
|
action="store_true",
|
|
help="Do not restart containers after backup",
|
|
)
|
|
|
|
p.add_argument(
|
|
"--dump-only-sql",
|
|
action="store_true",
|
|
help=(
|
|
"Create database dumps only for DB volumes. "
|
|
"File backups are skipped for DB volumes if a dump succeeds, "
|
|
"but non-DB volumes are still backed up. "
|
|
"If a DB dump cannot be produced, baudolo falls back to a file backup."
|
|
),
|
|
)
|
|
return p.parse_args()
|