initial commit
This commit is contained in:
commit
31d5668e24
|
@ -0,0 +1,4 @@
|
|||
FROM alpine:latest
|
||||
|
||||
RUN apk add --no-cache libarchive-tools zstd
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
image:
|
||||
docker build --pull -t localhost/archiver .
|
||||
|
||||
clean:
|
||||
docker rmi localhost/archiver
|
||||
|
||||
dump:
|
||||
mkdir -p dumps
|
||||
cd dumps && bash ../dump.sh
|
||||
|
||||
.PHONY: image clean
|
|
@ -0,0 +1,18 @@
|
|||
#!/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
|
|
@ -0,0 +1,26 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e -o pipefail
|
||||
|
||||
info() {
|
||||
[ "$#" -gt 0 ] && echo -e "\033[1m>>> $*\033[0m" >&2
|
||||
}
|
||||
|
||||
for i in *.json; do
|
||||
[ -f "$i" ] || continue
|
||||
vol_name=${i%.json}
|
||||
archive=$vol_name.tar.zst
|
||||
info "Recovering \"$vol_name\" from \"$archive\""
|
||||
|
||||
label_args=()
|
||||
readarray -t labels < <(jq -r '.[0].Labels | to_entries | .[] | .key + "=" + .value' "$i")
|
||||
for label in "${labels[@]}"; do
|
||||
label_args+=(--label "$label")
|
||||
done
|
||||
|
||||
set -x
|
||||
docker volume create "${label_args[@]}" "$vol_name"
|
||||
docker run --rm -v "$vol_name":/vol -v "$(readlink -f "$archive")":/vol.tar.zst:ro \
|
||||
localhost/archiver bsdtar -C /vol --numeric-owner -xf /vol.tar.zst
|
||||
set +x
|
||||
done
|
Loading…
Reference in New Issue