{"id":38697516,"url":"https://github.com/kmille/docker-dbdump","last_synced_at":"2026-01-17T10:42:44.407Z","repository":{"id":222725427,"uuid":"758211254","full_name":"kmille/docker-dbdump","owner":"kmille","description":"docker-dbdump – python script to create docker database backups","archived":false,"fork":false,"pushed_at":"2025-07-07T15:25:34.000Z","size":82,"stargazers_count":9,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-07T16:47:30.205Z","etag":null,"topics":["backup","database","docker"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kmille.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-02-15T20:57:08.000Z","updated_at":"2025-07-07T15:25:37.000Z","dependencies_parsed_at":"2024-02-17T18:26:12.701Z","dependency_job_id":"543b96db-979d-40b9-a0d1-326771ca8686","html_url":"https://github.com/kmille/docker-dbdump","commit_stats":null,"previous_names":["kmille/docker-dbdump"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/kmille/docker-dbdump","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kmille%2Fdocker-dbdump","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kmille%2Fdocker-dbdump/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kmille%2Fdocker-dbdump/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kmille%2Fdocker-dbdump/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kmille","download_url":"https://codeload.github.com/kmille/docker-dbdump/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kmille%2Fdocker-dbdump/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28506593,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T10:25:30.148Z","status":"ssl_error","status_checked_at":"2026-01-17T10:25:29.718Z","response_time":85,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["backup","database","docker"],"created_at":"2026-01-17T10:42:43.778Z","updated_at":"2026-01-17T10:42:44.388Z","avatar_url":"https://github.com/kmille.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# docker-dbdump - database backup for docker containers\n\nThis python script creates backups of databases which run in Docker containers. Please create an issue if you run into problems.\n\n## How does it work?\n1) Iterate over all running Docker containers\n2) Check if it's a database container (MySQL, MariaDB, PostgreSQL, PostgriSQL)\n3) If so, run mysqldump or the equivalent\n4) Use `-v`/`--verbose`, it's helpful\n\n## Features\n\n- Backups all database containers, a few specified ones or all containers with some exceptions\n- Creates [rsyncable](https://beeznest.wordpress.com/2005/02/03/rsyncable-gzip/) zip files (can be disabled with `--skip-gzip`)\n- Creates a state file (useful for monitoring) with `--update-state-file`\n- Always returns with exit code 0 unless you specify `--fail`\n\n## Getting started\n\nPlease check the `docker-compose.yml` in the repo. It spawns some db containers and creates a backup. Use `docker-dbdump -h` for more information.\n\n```\nvim docker-compose.yml\nsudo docker-compose up\n```\n\n## Installation\n\nusing [pip](https://pypi.org/project/docker-dbdump/):\n\n```\npip install docker-dbdump\n```\n\nUsing [docker](https://github.com/users/kmille/packages/container/package/docker-dbdump):\n\n```\ndocker pull ghcr.io/kmille/docker-dbdump:latest\n```\n\n**Warning**: When using the docker image, you have to mount the Docker socket (`-v /var/run/docker.sock:/var/run/docker.sock`).\n\nUsing docker-compose:\n\n```yaml\nservices: \n  docker-dbdump:\n    image: ghcr.io/kmille/docker-dbdump:latest\n    volumes:\n      - /var/run/docker.sock:/var/run/docker.sock\n      - /backups:/backups\n    command: \"docker-dbdump --all --verbose\"\n```\n\nUse `docker-compose -f /opt/container-backups/docker-compose.yml up` in cronjobs.\n\n## dev environment\n```bash\nsudo docker-compose up # run some DB container\nsudo poetry install\n\nkmille@linbox:docker-dbdump sudo poetry run docker-dbdump -h\nusage: [-h] [-v] [--backup-dir BACKUP_DIR] [-l [LIST]] [-a] [-b BACKUP [BACKUP ...]] [-i IGNORE_CONTAINER [IGNORE_CONTAINER ...]] [--skip-gzip] [-s] [--fail] [--version]\n\noptions:\n  -h, --help            show this help message and exit\n  -v, --verbose         print verbose output. Warning! This logs database passwords!\n  --backup-dir BACKUP_DIR\n                        output directory for backups\n  -l, --list [LIST]     show running docker containers. Add argument to grep\n  -a, --all             backup all running db containers\n  -b, --backup BACKUP [BACKUP ...]\n                        only backup specific containers\n  -i, --ignore-container IGNORE_CONTAINER [IGNORE_CONTAINER ...]\n                        backup all running db containers except the ones specified (can be used multiple times)\n  --skip-gzip           Do not create create rsyncable gzip dump\n  -s, --update-state-file\n                        update state file (/var/log/docker-dbdump.done) with current date if everything succeeds\n  --fail                if --fail is specified, the script will return with exit code 1 if an error occurs. If not specified, the exit code is always 0\n  --version             print version and exit\n```\n\n**Note**: If you use `--ignore-container` option multiple times, please use the format `-i container1 container2`.\n\n## Example output\n\n```bash\nkmille@linbox:docker-dbdump sudo poetry run docker-dbdump -l\ndocker-dbdump-maria-db-1       mariadb:11.2.2                 /home/kmille/projects/docker-dbdump\ndocker-dbdump-postgres-db-1    postgres:latest                /home/kmille/projects/docker-dbdump\ndocker-dbdump-postgis-db-1     postgis/postgis:latest         /home/kmille/projects/docker-dbdump\ndocker-dbdump-mysql-db-1       mysql:latest                   /home/kmille/projects/docker-dbdump\n\nkmille@linbox:docker-dbdump sudo poetry run docker-dbdump -l maria\ndocker-dbdump-maria-db-1       mariadb:11.2.2                 /home/kmille/projects/docker-dbdump\n\nkmille@linbox:docker-dbdump sudo poetry run docker-dbdump --all --verbose --update-state-file\n[2025-02-23 09:48:43,156 DEBUG] Dumping backups to /backups\n[2025-02-23 09:48:43,172 INFO] Starting to backup container docker-dbdump-postgis-db-1 (postgres)\n[2025-02-23 09:48:43,172 DEBUG] Running dump 'docker exec b94ef9366188a5ede0187f92b48f733e9bdbb88be28e9453acccb45343ea2a7d pg_dumpall --username 'test-user' | gzip --rsyncable \u003e /backups/_home_kmille_projects_docker-dbdump_docker-dbdump-postgis-db-1_test-user_postgres.sql.gz'\n[2025-02-23 09:48:44,056 DEBUG] Sucessfully dumped backup\n[2025-02-23 09:48:44,056 DEBUG] Checking backup with '['zgrep', '-q', '--', 'PostgreSQL database cluster dump', '/backups/_home_kmille_projects_docker-dbdump_docker-dbdump-postgis-db-1_test-user_postgres.sql.gz']'\n[2025-02-23 09:48:44,067 DEBUG] Created backup looks good\n[2025-02-23 09:48:44,067 INFO] Done backuping container docker-dbdump-postgis-db-1 (postgres)\n[2025-02-23 09:48:44,070 INFO] Starting to backup container docker-dbdump-postgres-db-1 (postgres)\n[2025-02-23 09:48:44,070 DEBUG] Running dump 'docker exec 3c6c7c220d34182d846127ea09fae1d2bd88b3ccd341a471eca8787522d782ed pg_dumpall --username 'postgres' | gzip --rsyncable \u003e /backups/_home_kmille_projects_docker-dbdump_docker-dbdump-postgres-db-1_postgres_postgres.sql.gz'\n[2025-02-23 09:48:44,399 DEBUG] Sucessfully dumped backup\n[2025-02-23 09:48:44,399 DEBUG] Checking backup with '['zgrep', '-q', '--', 'PostgreSQL database cluster dump', '/backups/_home_kmille_projects_docker-dbdump_docker-dbdump-postgres-db-1_postgres_postgres.sql.gz']'\n[2025-02-23 09:48:44,409 DEBUG] Created backup looks good\n[2025-02-23 09:48:44,410 INFO] Done backuping container docker-dbdump-postgres-db-1 (postgres)\n[2025-02-23 09:48:44,412 INFO] Starting to backup container docker-dbdump-maria-db-1 (mariadb)\n[2025-02-23 09:48:44,412 DEBUG] Running dump 'docker exec 91dafc7f3a3a7fdeec5bd3993df5bb96fac2a6e9b5334c8e3b4d6dcac5a39d58 mariadb-dump -u 'root' -p'mariadb-root-password' --single-transaction --skip-lock-tables --all-databases | gzip --rsyncable \u003e /backups/_home_kmille_projects_docker-dbdump_docker-dbdump-maria-db-1_root_mariadb.sql.gz'\n[2025-02-23 09:48:44,906 DEBUG] Sucessfully dumped backup\n[2025-02-23 09:48:44,907 DEBUG] Checking backup with '['zgrep', '-q', '-i', '--', '^-- mariadb dump', '/backups/_home_kmille_projects_docker-dbdump_docker-dbdump-maria-db-1_root_mariadb.sql.gz']'\n[2025-02-23 09:48:44,919 DEBUG] Checking backup with '['zgrep', '-q', '--', '^-- Host: localhost', '/backups/_home_kmille_projects_docker-dbdump_docker-dbdump-maria-db-1_root_mariadb.sql.gz']'\n[2025-02-23 09:48:44,930 DEBUG] Created backup looks good\n[2025-02-23 09:48:44,931 INFO] Done backuping container docker-dbdump-maria-db-1 (mariadb)\n[2025-02-23 09:48:44,933 INFO] Starting to backup container docker-dbdump-mysql-db-1 (mysql)\n[2025-02-23 09:48:44,933 DEBUG] Running dump 'docker exec 6482f3ed4c47ebaae9289614adcacdef92ee66f4581c5d1cc2e726d66ac0ae1c mysqldump -u 'root' -p'mysql-root-password' --single-transaction --skip-lock-tables --all-databases | gzip --rsyncable \u003e /backups/_home_kmille_projects_docker-dbdump_docker-dbdump-mysql-db-1_root_mysql.sql.gz'\n[2025-02-23 09:48:45,546 DEBUG] Sucessfully dumped backup\n[2025-02-23 09:48:45,546 DEBUG] Checking backup with '['zgrep', '-q', '-i', '--', '^-- mysql dump', '/backups/_home_kmille_projects_docker-dbdump_docker-dbdump-mysql-db-1_root_mysql.sql.gz']'\n[2025-02-23 09:48:45,558 DEBUG] Checking backup with '['zgrep', '-q', '--', '^-- Host: localhost', '/backups/_home_kmille_projects_docker-dbdump_docker-dbdump-mysql-db-1_root_mysql.sql.gz']'\n[2025-02-23 09:48:45,570 DEBUG] Created backup looks good\n[2025-02-23 09:48:45,570 INFO] Done backuping container docker-dbdump-mysql-db-1 (mysql)\n[2025-02-23 09:48:45,571 INFO] Updated state file /var/log/docker-dbdump.done\n[2025-02-23 09:48:45,571 INFO] Everything worked fine. Exiting with exit code 0.\n\nkmille@linbox:docker-dbdump cat /var/log/docker-dbdump.done\n2025-02-23 09:48:45.570701\nkmille@linbox:docker-dbdump ls -l /var/log/docker-dbdump.done\n-rw-r--r-- 1 root root 27 Feb 23 09:48 /var/log/docker-dbdump.done\n\nroot@linbox: file /backups/_home_kmille_projects_docker-dbdump_docker-dbdump-*\n/backups/_home_kmille_projects_docker-dbdump_docker-dbdump-maria-db-1_root_mariadb.sql.gz:         gzip compressed data, from Unix, original size modulo 2^32 3210314\n/backups/_home_kmille_projects_docker-dbdump_docker-dbdump-mysql-db-1_root_mysql.sql.gz:           gzip compressed data, from Unix, original size modulo 2^32 3763792\n/backups/_home_kmille_projects_docker-dbdump_docker-dbdump-postgis-db-1_test-user_postgres.sql.gz: gzip compressed data, from Unix, original size modulo 2^32 11915\n/backups/_home_kmille_projects_docker-dbdump_docker-dbdump-postgres-db-1_postgres_postgres.sql.gz: gzip compressed data, from Unix, original size modulo 2^32 1789\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkmille%2Fdocker-dbdump","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkmille%2Fdocker-dbdump","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkmille%2Fdocker-dbdump/lists"}