Package: docker-volume-dump
Docker volume dumpA tool to help archive data from container running in a docker container.Database backup support for Postgresql, Mysql/Mariadb: it create a backup in the container through docker API, then retrieves data to save
it in a proper place.rsyncvolume data: it introspect container and rsync all declaredlocal volumeandbindmount points.note: at the moment it's not possible to backup a database and rsync those volumes.UsageUsing dockerdockerrunregistry.gitlab.com/micro-entreprise/docker-volume-dumparchive--helpFor instance if you want to create dumps from different postgresql container in a docker swarm environment this would looks likes:docker service create \
          -d \
          --mode global \
          --name pgsql-dumps \
          --restart-condition none \
          --mount type=bind,src=/path-to-dump-storage/,dst=/backups \
          --mount type=bind,src=/var/run/docker.sock,dst=/var/run/docker.sock \
          --mount type=bind,src=/path-to-config-directory/,dst=/etc/archiver \
          --network sentry_internal \
          --with-registry-auth registry.gitlab.com/micro-entreprise/docker-volume-dump \
          archive -f /etc/archiver/logging.json -r -s '{"label": ["docker-volume-dump.project='$PROJECT'","docker-volume-dump.environment='$ENVIRONMENT'"]}'This script require access to the docker daemon to query docker labels.
It must be launched on each host using--mode global.Using pythonpipinstalldocker-volume-dump
archive--helpConfigurationThe main idea is to tell the container how to manage its backups using docker
labels, you can set following labels.You can use a custom prefix if you like so usingARCHIVER_LABEL_PREFIXenv variable. For instance if you setARCHIVER_LABEL_PREFIX=archiverit
would expect labels likesarchiver.isactiveinstead of the defaultdocker-volume-dump.isactive.docker-volume-dump.driver: Optional (pgsqlby default) kind of data to
dump (could be one ofpgsql,mysql,rsync). Only one value supported by
container.Note:mysqldriver is working for mariadb as welldocker-volume-dump.isactive: Takes no value. Used by the default selector
to determine if the Archiver backups are enabled on the container.docker-volume-dump.project: A project name (the container name if not set)docker-volume-dump.environment: An environment (staging, production, ...)docker-volume-dump.prefix: A prefix for the dump fileDatabase labels (pgsql/mysql)docker-volume-dump.dbname: Required, the database name to dump.docker-volume-dump.username: DB role used to dump the database.
Required withmysql, fallback topostgresif not set forpgsql.docker-volume-dump.password: DB password used to dump the db.
Required withmysql, not use withpgsqldriverThis will generate a file in a tree likes<project>/[<environment>/]<prefix><dbname><date>rsynclabelsnote: I've chosen torsyncdata first becausetar/gziprdiff-backupfailed to compress data if other programs write content
at the same time. My flow is something likedata->rsync->rdiff-backup->tar/gzip-> s3docker-volume-dump.rsync-params: params to add to rsync command
predifined (hardcoded) params arersync -avhP --deletedocker-volume-dump.ro-volumes: If set to one of those values["yes", "true", "t", "1"](not case sensitive) rsync read-only
volumes as well for the given container.This will generate a director per declared volume/bind<project>/[<environment>/][<prefix>]<computed folder name>Computed folder name is based on the path inside the container where
slash (/) are replaced per dash (-). ie:Project: testEnvironment: devprefix:rsynced_volume declare as-v /some/path/on/host/machine:/path/to/datavolume declare as-v named-volume:/other/datanote: if archiver is running inside a container where host
filesystem is mounted in/hostfsmind to use--host-fs /hostfsoption.Would produce:/backups/test/dev/rsynced_path-to-data/backups/test/dev/rsynced_other-dataRoadmappgsql/mysql: support multiple base per DBMSpgsql/mysql: if dbname is not provide retreive db list to detect the DB to dumpwondering if the way use to query docker labels is compliant with k8sIn swarm investigate to launch only once container (not on each hosts)