Options in backing up persistent docker volumes?

3 years ago by r0ckr to c/selfhosted

Hi all

I'm running several docker containers with local persistent volumes that I would like to backup. I haven't found an easy method to do so.

What do you use / recommend to do that? AFAIK you can't just rsync the volume directory while the container is running.

load all comments
outcide 19 points 3 years ago

Use bind mounts instead of docker volumes. Then you just have normal directories to back up, the same as you would anything else.

In general, it's not a problem to back up files while the container is running. The exception to this is databases. To have reliable database backups, you need to stop the container (or quiesce/pause the database if it supports it) before backing up the raw database files (including SQLite).

path: 0 345067, hotness: undefined, score: 19, children: 7
MaggiWuerze 2 points 3 years ago

This is your answer. It also has the benefit of allowing you to have a nice folder structure for your Docker setup, where you have a folder for each service holding the corresponding compose yaml and data folder(s)

path: 0 345067 347627, hotness: undefined, score: 2, children: 0
Edo78 2 points 3 years ago

it's better to stop the service mounting those volumes before backing them up or you may break something with hot backup

path: 0 345067 345793, hotness: undefined, score: 2, children: 0
mirisbowring 2 points 3 years ago

Exactly the reason why i always exchange the volumes in any compose file with bind mounts.

Also you donβ€˜t have the provlem of many dangling volumes

path: 0 345067 346028, hotness: undefined, score: 2, children: 3
asjmcguire 1 point 3 years ago

I don't even understand what the advantage is to using volumes rather than mounts? So I too always use mounts.

path: 0 345067 346028 347466, hotness: undefined, score: 1, children: 2
fox 0 points 3 years ago

docker volume is an exact same normal directory under /var/lib/docker, there's no difference with regard to backup consistency.

there's no silver bullet here, it's best to use tools specific to whatever is running in the container i.e. wal-g for postgres, etc.

path: 0 345067 345472, hotness: undefined, score: 0, children: 0
selfhosted
selfhosted

@lemmy.world

login for more options
63050
6824
6401

A place to share alternatives to popular online services that can be self-hosted without giving up privacy or locking you into a service you don't control.

Rules:

Detailed Rules Post

  1. Be civil.

  2. No spam.

  3. Posts are to be related to self-hosting.

  4. Don't duplicate the full text of your blog or readme if you're providing a link.

  5. Submission headline should match the article title.

  6. No trolling.

  7. Promotion posts require active participation, with an account that is at least 30 days old. F/LOSS without a paywall has exceptions, with requirements. See the rules link for details. Tags [CBH] or [AIP] are required, see the links in Rule 8 for details.

  8. AI-related discussions and AI-involved promotional posts have additional requirements for tagging, as noted in Rule 7 and the AI & Promotional Post Expanded Rules post, and find example disclosures here.

Resources:

Any issues on the community? Report it using the report flag.

Questions? DM the mods!

go to feed...