3

Be there a machine that runs various docker projects. Each docker container is regularly replaced/stopped/started as soon as newer versions arrive from the build system.

How does a backup concept for such a machine look like?


Looking into similar questions [1] the correct path to a working backup/restore procedure is not immediately clear to me. My current understanding is something like:

Backup

  1. Use scripts to create images and containers. Store/Backup scripts in your favorite Version Control System. Use version tags to pull docker images. Don't use latest tag.
  2. Exclude /var/lib/docker/overlay2 from backup (to prevent backing up dangling and temporary stuff)
  3. Use named volumes only. Volumes can be saved and restored from backup. For database stuff extra work has to be done. Eventually consider to tar volumes to extra folder [2].
  4. docker prune daily to remove dangling stuff

Restore

  1. Make sure all named volumes are back in place.
  2. Fetch scripts from version control to recreate images as needed. Use docker run to recreate containers.
  3. Application specific tasks - restore databases from dumps , etc.

[1] How can I backup a Docker-container with its data-volumes?

[2] https://stackoverflow.com/a/48112996/1485527

jschnasse
  • 8,526
  • 6
  • 32
  • 72

1 Answers1

2
  • Don't use latest tag in your images. Set correct tags (like v0.0.1, v0.0.2, etc) for your images and you can have all of your versions in a docker registry.
  • You should prefer to use stateless container
  • What is about docker volume? You can use it https://docs.docker.com/storage/volumes/
  • If you use bind mount volume you can manually save you files in archive for backup
coaxium
  • 113
  • 1
  • 5