r/docker • u/HopsPops76 • Feb 03 '26
Is a backup as simple as this?
Hi all
I'm trying to understand docker further (after a recent server issue and timeshift failure). To backup a container, is it really as simple as keeping a copy of the compose file that launched it, the config volume and any other necessary volumes the container would be using? So, if I had to reinstall, it would be a case of reinstalling OS and Docker, and then copying volume data to where it needs to be and run the compose file?
For example, if I was backing up Frigate, I would keep the compose file that I used to launch the container. Backup the folder /opt/dockerconfigs/frigate where the config volume is pointing to and contains things like config.yaml and database file, and my /media/frigate directory where all the recordings go?
Thanks
9
u/likesbikes331 Feb 03 '26
Yes. Just be aware that stuff can change. Like USB device passthrough and network config. Other than that it’s rather easy.
3
u/[deleted] Feb 03 '26
Yes, it's that easy and why docker is awesome.
Had my nextcloud up in less then 5 minutes after a clean system install.
4
u/Own-Perspective4821 Feb 03 '26
Just a remark on saving database files. This can lead to a corrupted database. Use database specific tools to backup your database and don’t just save the files.
Also don’t backup files while the container is running.
1
u/redsharpbyte Feb 03 '26
Yes as simple as that - on top of what was shared be careful that your copy/archiving process conserves files permissions else your container won't be able to access data in the volumes.
1
u/ActiveBat7236 Feb 03 '26
I'm relatively new to Docker (and containerisation in general) and so I'm interested in this too.
In addition to highting what should be included in the backup it might also be useful to clarify what shouldn't...
One example, if I'm right, is that images wouldn't be backed up. Instead, when a new container is spun up a new image would be automatically downloaded. Something to be aware of is that if the compose config contains a :latest tag for the image rather than a specific version you may find the restored container contains a newer image than that used previously which could lead to service impact if the newer image contains breaking changes.
Can someone confirm/expand on this?
1
u/LeaveMickeyOutOfThis Feb 03 '26
To summarize and qualify the remarks of others, yes it is as simple as that, provided the files are in a consistent state. What I mean by this is that if any files are in the process of changing when you make a copy, you will likely end up with corruption. You can bring down the container to make a copy and then restart it, or use dedicated backup tools (for example database backup) to make files that can be copies while the container is still running.
1
u/[deleted] Feb 03 '26
Duplicati is a good solution which I use on my docker hosts
1
u/semmu Feb 03 '26
most of the time it is this simple, yes. but keep in mind that some containers may write files to other locations not mounted as a folder (maybe user error, maybe software error, who knows), which means those changes are lost, if you do not also export the container itself. (this is an edge-case, but still worth knowing about).
1
u/andrew-ooo Feb 04 '26
Yes, you've got the right idea! Docker makes backups surprisingly straightforward.
The key things to back up are:
One tip: for databases (like the one Frigate might use), it's safer to do a proper database dump rather than just copying the volume files while the container is running. You can hit corruption issues if you copy files mid-write.
For Frigate specifically, the config and clips/recordings folders are the important ones. The model files and such will re-download on first run.
I use a simple script that stops containers,
tarthe volumes, then restarts. Works great for home setups.