docker-volume-dump/dump.sh

19 lines
421 B
Bash
Raw Normal View History

2022-09-19 05:41:35 +09:00
#!/bin/bash
set -e -o pipefail
info() {
[ "$#" -gt 0 ] && echo -e "\033[1m>>> $*\033[0m" >&2
}
readarray -t volumes < <(docker volume ls --format "{{ .Name }}")
for v in "${volumes[@]}"; do
info "Dumping \"$v\""
docker run --rm -v "$v":/vol:ro localhost/archiver sh -c \
"bsdtar -C /vol --numeric-owner -c . | zstdmt -15v" \
> "$v".tar.zst
docker volume inspect "$v" > "$v".json
done