Skip to content

Instantly share code, notes, and snippets.

@sverhoeven
Last active March 16, 2023 06:58
Show Gist options
  • Save sverhoeven/482ac14ffe1e3bc5b8dff6d91cb37b9d to your computer and use it in GitHub Desktop.
Save sverhoeven/482ac14ffe1e3bc5b8dff6d91cb37b9d to your computer and use it in GitHub Desktop.
Backup of images of my orgnizations on Docker Hub

Backup of my organizations on Docker Hub

Needs https://github.com/docker/hub-tool, xz and jq

hub-tool login
hub-tool org ls --verbose
# Dies
# Create orgs.txt from log
cat orgs.txt |xargs mkdir -p
cat orgs.txt | xargs -I % hub-tool repo ls --format json % | jq -r '.[].Name' > repos.txt
cat repos.txt | xargs -I % hub-tool tag ls --format json % | jq -r '.[].Name' > tags.txt

Prune tags.txt, to remove old versions and latest tags which have version next to it.

cat tags.txt | xargs -I % sh -c 'docker pull %;docker image save % | xz -T 0 > %.tar.xz;docker rmi -f %'
@sverhoeven
Copy link
Author

compress with multiple threads

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment