Giter Club home page Giter Club logo

docker-db-auto-backup's Introduction

docker-db-auto-backup

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

Supported databases

  • MariaDB
  • MySQL
  • PostgreSQL
  • Redis

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.

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
  • plain (no compression - the default)

Example docker-compose.yml

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.

docker-db-auto-backup's People

Contributors

realorangeone avatar renovate[bot] avatar renovate-bot avatar j-n7 avatar cz3k avatar kzshantonu avatar pagdot avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.