2

Docker stores its containers, volumes, and images in a collection of large files under /var which is not the greatest thing for backing up incrementally.

With Bareos, I understand that backing up MySQL databases has the same issue and can be done with bpipe.

How can I backup Docker containers (and images, although there's another solution to that*) so that they are easily able to be restored to the same machine or another one?

*(There's also docker registry, which will let you push images to a remote repository, which works a bit like a backup also, but without the backup mindset. And it only works for images, not containers or volumes.)

1

For images, one way you can do this is to use the save command offered by Docker. By running:
$ docker save --output output_filename.tar your_image, Docker will save the image you have specified to a tar file within the directory you are currently in. You are then able to save this image, or move it to another machine.

For containers, you can use the export command. This will save the contianer's filesystem to a tar file. This is done by running: docker export --output="output_filename.tar" your_container.

For using the image, you can use the load command to import the tar file. This can be done by running: $ docker load --input your_image.tar.

  • Yes, but how does that work with BareOS or Bacula? They both handle things like incremental and differential backups which obviously would be very resource intensive if we were to docker save or docker export every time. – tudor Sep 1 '18 at 16:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.