Docker container (bind-) mount discovery and backup tool
- Discover bind mounts attached to a specified container or service
- Back up these bind mounts to a destination of your choosing
- Gracefully shuts down the container/service before backing up, and starts it up again after backing up
- (Optionally) Archive the backup so it is stored in a timestamped .tar.gz file for easy organising
- Allows for exluding mounts via config.yaml
- Discovery is done using the Docker Socket (/var/run/docker.sock)
- Backup of files is done by spinning up an rclone container, whilst (read-only) binding the specified container's mounts as a source.
- Destination folder is overwritten if contents have changed, will not touch anything else
- Archival is done using
taron an alpine container, binding the finished backup as a source and writing it to the same location as $containername-$timestamp.tar.gz
There is a config.dist.yaml file included that serves as an example of what the config can do. Copy it to config.yaml and mount it accordingly to enable it.
By default --backup all will scan for all mounts and back them up. You can ignore certain mounts, so they wont be backed up.
For example:
- Plex media library
- Some app that has a (large) database you dont necessarily need TODO: Exlude certain folders/files in mount using the rclone exclude command. For now this supports only whole mounts. Large files along config files in the same mount will require you to separate those files/folders into further container mounts
docker run \
-v /var/run/docker.sock:/var/run/docker.sock \
--name mountnsync \
dockerdaan/mountnsync:latest \
--backup all --type container --destination /your/backup/location <containername>
This will create a backup of all $containername mounts in /your/backup/location/$containername/mounts/{$mount1,$mount2,etc..}
docker run \
-v /var/run/docker.sock:/var/run/docker.sock \
--name mountnsync \
dockerdaan/mountnsync:latest \
--backup all --type container --destination --archive /your/backup/location <containername>
The --archive flag will create an archive of the latest backup in /your/backup/location/$containername/archives/$containername$timestamp.tar.gz
docker run \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /your/config.yaml:/app/config.yaml \
--name mountnsync \
dockerdaan/mountnsync:latest \
--backup all --type service --destination --archive /your/backup/location <servicename>_<taskname>
The --archive flag will create an archive of the latest backup in /your/backup/location/$containername/archives/$containername$timestamp.tar.gz