Whats the best way to backup docker
I've realized that I get more and more in contact with docker. I don't really mind, it works really well, however my experience is limited so I mostly just figure out stuff as I go.
But, it has come to the point that I feel that I should start doing stuff "the right way". Most of it I have already figured out, but when it comes to backing up containers it seems like there are many different schools. Some people save the containers as images, other use data volumes for everything, and some even run containers to backup other containers.
So far I have been managing by using data volumes and remote sql dumps, but it's getting to be a bit to much to manage. There must be a correct way to do it, or at least a few "don't do it" ways.
I figure a lot of people here must run docker, so whats your back up strategy?
cron job starts a container in same network -- do the backsup ; sqldump etc ... to an nfs volume.
Yeah, I've been playing around with solutions like that, but I feel it does not really scale well.
If new networks are created and you forgot to make a backup container for them then you miss something. It should be scriptable without too much effort I guess, but I cant help thinking there must be a better way.
That might not be the "right" way, but currently, i am pretty well using Proxmox in combination with proxmox backup manager - whole Docker-VMs are getting backed up, while you also have the option to extract single folders, while you also have the option to backup single folders with .sql files and the like with scripting using the proxmox backup client. On one of my older setups, .sql files from databases are getting pushed into the proxmox backup server every hour. All Proxmox Backup Server backups are deduplicated (via "chunks" so expect many thousands of files), compressed and optionally encrypted (but this can slow down the recovery process, so beware).
One negative is that the proxmox backup client is currently only available for Debian 10/11 or Ubuntu 20.04.
Backing up entire vm's is another thing, I already have that covered.
have a look on using borgbackup to backup volumes
Fuck this 24/7 internet spew of trivia and celebrity bullshit.
This is not recommended but doable:
You’ll usually find the content of your volumes in /var/lib/docker/volumes. Each volume gets its own subdirectory, such as /var/lib/docker/volumes/mysql. Within this top-level path you’ll find a _data folder which contains all the files stored inside the volume.
Archiving the /var/lib/docker/volumes directory can be a convenient way to quickly backup everything on your host. You’ll need to use sudo though because everything under this path is owned by root.
Backing up volumes in this way isn’t recommended for regular use because it’s not portable across installations. Docker’s volume driver system means volume data won’t necessarily be stored on your host’s filesystem – it could be on a network share or another remote location. This technique should only be attempted when you want a quick backup before you run maintenance on a specific machine
The best way to backup Docker containers and their data is to first create a backup of the Docker environment, including any volumes and network information. This can be done with the docker-compose command, by running docker-compose down to stop and remove all containers and then running docker-compose up -d to recreate them.
Next, you can backup the individual container data by exporting them as images with the docker export command. For example, docker export mycontainer > mycontainer.tar would create a tar file of the container's filesystem.
Finally, you should also backup any persistent data volumes with either a file-level backup or a tool like docker volume backup.
Buy a second pair of dockers
VPS reviews and benchmarks |
Docker containers are supposed to be treated as ephemeral
You can never have too many khakis.