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
- 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.
- Exclude
/var/lib/docker/overlay2
from backup (to prevent backing up dangling and temporary stuff) - 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].
docker prune
daily to remove dangling stuff
Restore
- Make sure all named volumes are back in place.
- Fetch scripts from version control to recreate images as needed. Use
docker run
to recreate containers. - Application specific tasks - restore databases from dumps , etc.
[1] How can I backup a Docker-container with its data-volumes?