百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
D

docker-db-auto-backup

> 数据库
开源

一个脚本,用于在主机上自动备份所有在 Docker 环境下运行的数据库

200 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

一个脚本,用于在主机上自动备份所有在 Docker 环境下运行的数据库

docker-db-auto-backup

A script to automatically back up all databases running under docker on a host, with optional compression support.

Supported databases

  • MySQL
  • MariaDB
    • LSIO's MariaDB
  • PostgreSQL
    • TimescaleDB
    • pgvecto.rs
    • pgvector,
    • Nextcloud's AIO
    • pgautoupgrade
    • Immich's Postgres VectorChord
  • Redis

If your database isn't detected automatically, you can specify using the db-auto-backup label (configurable using $AUTO_BACKUP_LABEL):

yaml
services:
  valkey:
    image: valkey/valkey:9
    labels:
      - "auto-backup=redis"  # Backup as if it were redis

  my_custom_database:
    image: some.private.host/organization/custom_database:latest
    labels:
      - "auto-backup=postgres"  # Force identification as postgres

  unimportant:
    image: postgres:18
    labels:
      - "auto-backup=false" # Skip backup

Installation

This container requires access to the docker socket. This can be done either by mounting /var/lib/docker.sock, or using a HTTP proxy to provide it through $DOCKER_HOST.

Mount your backup directory as /var/backups (or override $BACKUP_DIR). Backups will be saved here based on the name of the container. Backups are not dated or compressed.

Backups run daily at midnight. To change this, add a cron-style schedule to $SCHEDULE. For more information on the format of the cron strings, please see the croniter documentation on PyPI.

Output is intentionally limited, to avoid polluting container logs. Set $DEBUG to something other than "false" to show additional details.

Success hooks

When backups are completed successfully, a request can be made to the URL defined in $SUCCESS_HOOK_URL. By default, a GET request is made. To include logs, also set $INCLUDE_LOGS to a non-empty value, which sends a POST request instead with helpful details in the body.

Note: Previous versions also supported $HEALTHCHECKS_ID, $HEALTHCHECKS_HOST and $UPTIME_KUMA_URL, or native support for healthchecks.io and Uptime Kuma respectively. These are all still supported, however $SUCCESS_HOOK_URL is preferred.

Compression

Files are backed up uncompressed by default, on the assumption a snapshotting or native compressed filesystem is being used (eg ZFS). To enable compression, set $COMPRESSION to one of the supported algorithms:

  • gzip
  • lzma / xz
  • bz2
  • zstd
  • plain (no compression - the default)

Example docker-compose.yml

yaml
version: "2.3"

services:
  backup:
    image: ghcr.io/realorangeone/db-auto-backup:latest
    restart: unless-stopped
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - ./backups:/var/backups
    environment:
      - SUCCESS_HOOK_URL=https://hc-ping.com/1234
      - INCLUDE_LOGS=true

Oneshot

You may want to use this container to run backups just once, rather than on a schedule. To achieve this, set $SCHEDULE to an empty string, and the backup will run just once. This may be useful in conjunction with an external scheduler.

Issues· 18 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Pythonbackupdatabasedockermariadb

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类数据库
定价开源

> 相关工具

P
PostgreSQL
功能强大的开源关系型数据库
R
Redis
内存数据结构存储,常用作缓存与队列
M
MySQL
广泛使用的开源关系型数据库