When to run this
Monthly, and additionally after any change that adds a volume or a bind mount to a production stack. Thirty minutes on a host with a dozen containers. The output is a list of paths that hold data, which is the artefact most teams discover they do not have on the day they need to restore something.
How to run it
Run it on the host, as a user in the docker group or via sudo.
Three items need root beyond that: uid-gid-correct reads inside
/var/lib/docker/volumes, selinux-labels reads the enforcement
mode, and capacity-headroom sizes the volumes tree.
Two items take a specific target rather than sweeping the host. Set them before you run:
VOLUME=platform_pgdata
CONTAINER=platform-db-1
The volumes-in-backup-set item compares against
/etc/backup/volumes.include. If your backup tool keeps its include
list somewhere else, point the second half of the comm at that file
instead — the check is only as good as the file it compares against,
and comparing against a stale list is worse than not running it.
Run no-data-in-writable-layer last. docker inspect --size walks
every container’s writable layer and takes tens of seconds per
container on a busy host.
Reading the results
Most commands here print only the problems: no-anonymous-volumes,
volumes-in-backup-set, bind-sources-exist,
no-sensitive-host-paths, no-shared-writable-volume,
no-data-in-writable-layer, production-volumes-external and
no-prune-in-automation are all silent on a healthy host. A page of
empty output is the result you want.
The remainder print evidence for a human to judge —
named-volumes-inventoried, read-only-where-possible,
volume-drivers-reviewed, capacity-headroom. Read those; do not
tick them because the command exited zero.
Four items have no command: restore-tested,
no-bind-over-populated-path, nfs-mount-options and
destruction-path-documented. Nothing on the host can prove any of
them, and restore-tested is the single most important line on this
page.
Evidence and sign-off
Record the volume inventory and its owners, the date of the last successful restore test, and any exception you granted with its expiry.
- Volumes reviewed: ______ Unowned: ______ Not in backup: ______
- Last successful restore test: ___________
- Operator: _________________ Date: ___________
- Reviewer: ________________ Date: ___________