mirror of
https://github.com/kevinveenbirkenbach/docker-volume-backup.git
synced 2025-12-29 19:46:42 +00:00
test(e2e): add dump-only-sql mixed-run + CLI contract coverage
- rename dump-only flag to --dump-only-sql across docs and tests - update backup logic: skip files/ only for DB volumes when dumps succeed; fallback to files when dumps fail - extend e2e helpers to support dump_only_sql - add e2e mixed-run regression test (DB dump => no files/, non-DB => files/) - add e2e CLI/argparse contract test (--dump-only-sql present, --dump-only rejected) - fix e2e files test to expect file backups for non-DB volumes in dump-only-sql mode and verify restore - update changelog + README flag table https://chatgpt.com/share/69522d9c-ce08-800f-9070-71df3bd779ae
This commit is contained in:
@@ -149,17 +149,20 @@ def main() -> int:
|
||||
database_containers=args.database_containers,
|
||||
)
|
||||
|
||||
# dump-only logic:
|
||||
if args.dump_only:
|
||||
if found_db and not dumped_any:
|
||||
print(
|
||||
f"WARNING: dump-only requested but no DB dump was produced for DB volume '{volume_name}'. Falling back to file backup.",
|
||||
flush=True,
|
||||
)
|
||||
# continue to file backup below
|
||||
else:
|
||||
# keep old behavior: skip file backups
|
||||
continue
|
||||
# dump-only-sql logic:
|
||||
if args.dump_only_sql:
|
||||
if found_db:
|
||||
if not dumped_any:
|
||||
print(
|
||||
f"WARNING: dump-only-sql requested but no DB dump was produced for DB volume '{volume_name}'. Falling back to file backup.",
|
||||
flush=True,
|
||||
)
|
||||
# fall through to file backup below
|
||||
else:
|
||||
# DB volume successfully dumped -> skip file backup
|
||||
continue
|
||||
# Non-DB volume -> always do file backup (fall through)
|
||||
|
||||
|
||||
|
||||
# skip file backup if all linked containers are ignored
|
||||
|
||||
@@ -68,10 +68,15 @@ def parse_args() -> argparse.Namespace:
|
||||
action="store_true",
|
||||
help="Do not restart containers after backup",
|
||||
)
|
||||
|
||||
p.add_argument(
|
||||
"--dump-only",
|
||||
"--dump-only-sql",
|
||||
action="store_true",
|
||||
help="Only create DB dumps (skip ALL file rsync backups)",
|
||||
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()
|
||||
|
||||
Reference in New Issue
Block a user