mirror of
https://github.com/kevinveenbirkenbach/docker-volume-backup.git
synced 2026-08-02 13:02:41 +00:00
feat(backup): exclude a volume by name, not only by image
volume_is_fully_ignored can only skip a volume when every container using it is ignored, so a container holding a derived tree next to state that must be kept cannot express the exclusion at all. The matrix docker-in-docker runner is exactly that: matrix_mdad_docker, matrix_mdad_matrix and matrix_mdad_state all hang off one container, and the derived one is an inner overlay2 store that no rsync in the chain can restore faithfully (none carries -X, so trusted.overlay.* is stripped in both directions). --volumes-no-backup-required names volumes directly. The check runs before containers_using_volume, so an excluded volume costs no docker call and the decision no longer depends on which containers happen to exist at backup time. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -54,6 +54,14 @@ def main() -> int:
|
||||
|
||||
for volume_name in docker_volume_names():
|
||||
print(f"Start backup routine for volume: {volume_name}", flush=True)
|
||||
|
||||
if volume_name in args.volumes_no_backup_required:
|
||||
print(
|
||||
f"Skipping volume '{volume_name}' entirely (declared no-backup).",
|
||||
flush=True,
|
||||
)
|
||||
continue
|
||||
|
||||
containers = containers_using_volume(volume_name)
|
||||
|
||||
if volume_is_fully_ignored(containers, args.images_no_backup_required):
|
||||
|
||||
@@ -68,6 +68,13 @@ def parse_args() -> argparse.Namespace:
|
||||
help="Exact image references (repo:tag, incl. any registry prefix) for which no backup should be performed",
|
||||
)
|
||||
|
||||
p.add_argument(
|
||||
"--volumes-no-backup-required",
|
||||
nargs="+",
|
||||
default=[],
|
||||
help="Exact volume names that are never backed up, whatever containers use them. For derived trees a restore cannot reproduce, above all a nested docker data root",
|
||||
)
|
||||
|
||||
p.add_argument(
|
||||
"--everything",
|
||||
action="store_true",
|
||||
|
||||
Reference in New Issue
Block a user