Create your backups based on docker labels
Project description
Docker volume dump
A tool to help archive data from container running in a docker container.
At the moment postgresql and mysql/mariadb dumps are supported.
Usage
Using docker
docker run registry.gitlab.com/micro-entreprise/docker-volume-dump archive --help
For 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 python
pip install docker-volume-dump
archive --help
Configuration
The main idea is to tell the container how to manage its backups using docker labels, you can set following labels
-
docker-volume-dump.driver: Optional (
pgsql
by default) kind of data to restore (could be one ofpgsql
,mysql
)Note:
mysql
driver is working for mariadb as well -
docker-volume-dump.isactive: Takes no value. Determine if the Archiver backups are enabled on the container. Default selector to get containers to handle.
-
docker-volume-dump.driver: The Archiver driver to use (pgsql, mysql). Only one value supported by container
-
docker-volume-dump.dbname: Required if database driver, the database to save
-
docker-volume-dump.username: DB role used to dump the db
-
docker-volume-dump.password: DB password used to dump the db. Required if driver is mysql
-
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 file
This will generate a file in a tree likes
<project>/[<environment>/]<prefix><dbname><date>
Realase process
pip install -U pip wheel bump2version twine
python setup.py sdist bdist_wheel
twine check dist/*
twine upload
Roadmap
- setup pre-commit with common lint tools
- automaticaly publish on pypi
- Handle volume data files
- wondering if the way use to query docker labels is compliant with k8s
- In swarm investigate to launch only once container (not on each hosts)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file docker-volume-dump-0.3.0.tar.gz
.
File metadata
- Download URL: docker-volume-dump-0.3.0.tar.gz
- Upload date:
- Size: 6.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c7fa30649412bc113593f2f86d16d2713caf78a5a7a54896fa809c9de0cf11aa |
|
MD5 | b1de8850d41355ba668d838697beb56e |
|
BLAKE2b-256 | 10f5c880a92de80363e77a9678bb12aa23732cf5482dd0e01832925709b152de |
File details
Details for the file docker_volume_dump-0.3.0-py3-none-any.whl
.
File metadata
- Download URL: docker_volume_dump-0.3.0-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2d71d33b79aca44664024288caa2103d67375be27208f17411e7c190543af6c5 |
|
MD5 | d4334463c4cbfbf08a063aaeae5bcf45 |
|
BLAKE2b-256 | b6358d5b239070282289c594941087ad95c5a305a1700014db7089ba76902d6b |