Docker Community Forums

Share and learn in the Docker community.

Docker configuration backup/recovery

I installed Docker on my Raspberry Pi (4B 8GB), and several containers are running, mostly Home Automation related (Home Assistant, Node-RED, Zigbee2MQTT, MQTT, Portainer, NginX, etc.)

Several of these containers run with volumes stored at different locations.

I would like to improve the Docker configuration, so I have all related volumes in 1 place so I know what to backup in order to recover my Raspberry environment.

Anyone a suggestion how to do this ?
What application do you use for backing up all data?

I installed Duplicati, but haven’t configured it yet. But it will take up a lot of space backing up all containers all the time.
Curious how you take care of this ?

Hi

Depending on your backup plan, in Duplicati, yes it will take some space, if you plan of having a history of X days.

Where to do you back it up, NAS? Because the easy way would just to copy your mountpoints to the nas every night or something?

I myself use https://kopia.io/, same idea as Duplicati

1 Like

Hi,

Thank you for the information.
Yes, I have a NAS to which I would like to backup the content.

For as far as I am aware, most of the content consists of images, that can be downloaded anytime. So I’ld like to backup efficiently, where only content other than images is on the backup. so the whole configuration.

I don’t mind making one backup of the images to the NAS, but I think it is a wast of time and space to backup all images multiple times a week.

If you do an incremental backup, I suppose the Images will be excluded of the backup after the first full has been done, right?
What is your backup configuration ?

Hi

You wont need the images, if you use docker compose, then the docker-compose.yml, and the DATA you use in the containers, normally you would map a directory to your container, then i backup that directory.

An example of this, I have a Splunk server running in a container, when i run this container, i map a data directory into the splunk container, so if i need to update my Splunk application/container, all my data isnt lost.
In a normal docker run command, thats the “-v /local/directory:/container/directory” argument.

then i have setup, to backup only /local/directory, because thats where the important data is (for this application), because the images can i always re-download from hub.docker.com

I have great interest in learning. That’s why I joined here. Thank you so much!

Ok, thanks, I think I understand. it’s just that i am not really confident of where all data is stored. When I look into Portainer, and open the configuration of a container, I can see information regarding volumes.
It is called: “Host/volume” and “Path in container”

If I understand well, for all containers I can backup the volumes listed in the “Host/volume” overview, to have all relevant data. Is that right, or are there still other places where the container data can reside?

Hi again

When you create the container, you SHOULD define some form of volumes/host folder mapping, else if you need to recreate your container (maybe an update) it will destory the data also.

But as you mentioned, do you have anything under “Host/volume” ? maybe attach a screenshot if possible.

Hi I understand what you say. Most of the containers have been created with a docker-compose script. these scripts mostly contain the volume/host folder mapping. although as wasn’t that familiar with docker, so there is not much consistency in it. Volumes seem to live on different locations now. I’d rather have 1 folder (as you mention “volumes”) that contains all volumes, so I know what I need for backup.

But if I am able to locate the volumes, I might also be able to move them to another location, right ? would it be that simple to switch the container off, move the volume and adjust config (where?) and start it again?

Attached you can find a few screenshots, there is no volume folder. From portainer I can see the mapping that is made. but as mentioned, where to adjust the config if I move the volume to another location?

By the way, a volume is not much more than a folder with sub-folders/files right ? it is not what I would expect on single file which is mounted.

Volumes.pdf (211.1 KB)

No, docker volumes are more internal in docker, the right way would be, as you said, stop the container, move the data to its new location, edit the compose file to reflect that change, then run docker-compose up -d to make the change live on the container.

When you created the container, you typed in the “old” directory, then it will always look in that directory, so when you edit the docker-compose file, and run docker-compose up -d (or how you do it in portainer) it will delete the container, and start it again with the new path.

Hope it makes sense :slight_smile:

Ok, thank you for the clarification. this definitely makes sense.
I’ll give it a try. Let’s see if I can create a new container with the right settings without deleting the old one. so I’ll be able to revert back to the previous situation.