Skip to content

Instantly share code, notes, and snippets.

@bkyle
Created March 8, 2021 15:13
Show Gist options
  • Save bkyle/56edda7f07e5b48ec1b98ad61fcace1b to your computer and use it in GitHub Desktop.
Save bkyle/56edda7f07e5b48ec1b98ad61fcace1b to your computer and use it in GitHub Desktop.
Backup the contents of docker images
container=""
bindings=$(docker inspect ${container} | jq -r '.[].HostConfig.Binds[]')
echo ${bindings} | while read bind; do
volume=${bind/:*/}
mount_point=${bind/*:/}
echo "docker run --volumes-from ${CONTAINER} -it --rm -v $(pwd)/backups:/backups busybox tar -czvf /backups/${volume}.tar.gz \"${mount_point}\""
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment