Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The docker VM is out of space. And you have dangling docker images. Do

docker image prune

Backing up docker data volumes

I've hit some troubles recently that have caused my docker data volumes to go bye-bye, which means I then lose an hour+ to re-provisioning my devstack.  So, here are some commands for making backups of data volumes:

Code Block
docker run -it -v devstack_mysql_data:/volume -v /tmp:/backup ubuntu:xenial tar -czf /backup/devstack_mysql_data.tar.gz -C /volume ./
docker run -it -v devstack_mongo_data:/volume -v /tmp:/backup ubuntu:xenial tar -czf /backup/devstack_mongo_data.tar.gz -C /volume ./
docker run -it -v devstack_elasticsearch_data:/volume -v /tmp:/backup ubuntu:xenial tar -czf /backup/devstack_elasticsearch_data.tar.gz -C /volume ./

So those backups should now live under the /tmp directory on your host.  I recommend moving them somewhere more permanent (like ~/data/docker_volume_backups).  You should be able to restore these as follows:

Code Block
docker run -it -v devstack_mysql_data:/volume -v /tmp:/backup ubuntu:xenial bash -c "rm -rf /volume/* ; tar -C /volume/ -xzf /backup/devstack_mysql_data.tar.gz"

Ideally, I would create a script to do the backups and then add it to a daily cron, rotating out old backups periodically.