If, like me, you deployed the JupyerHub docker spawner without persistent volumes and then ended up with tons of users having tons of content to lose, this may help you.
This short bash script will list all containers and then copy out their contents and zip it up to save space.
#!/bin/bash mkdir -p ~/notebook-backup cd ~/notebook-backup CONTAINERS=`docker container ls | grep -v PORTS | awk '{print $14}'` for NAME in ${CONTAINERS} do echo "Copying out files for ${NAME}; this may take a minute." docker cp ${NAME}:/home/notebook ./${NAME} echo "Zipping files for ${NAME}." tar -zcvf ${NAME}.tar.gz ${NAME} echo "Removing source files for ${NAME}." rm -rf ./${NAME} done