Scripting snapshot of all docker volumes on a host?

#1

I’m looking to set up a cron-able script that goes through every docker volume on a host system and snapshots it

Seems like something someone must be doing already but I didn’t find any relevant topic on the forum. I have some thoughts on how to go about it but what to poll first if anyone has experience doing this or any snippets they can share

The behavior I’m looking for is a script I’d run on the docker host machine that would go through the output of docker volume ls and for each target, run a temporary restic container that mounts that volume read-only and bind-mounts a local restic repository directory and saves a snapshot with a reasonable use of cache and useful host+path metadata recorded

#2

I wrote this script for myself using an rsync container. You could probably adapt it pretty easily to a container with Restic instead of rsync.

#3

Bivac could be an option. It uses restic under the hood.