Code Monkey home page Code Monkey logo

docker-pgdumper's Introduction

PGdumper setup for Docker

A very simple image that makes dumps from a Postgres service using pg_backup_rotated.sh, to be used in conjunction with a backup service. Docker hub repository.

Example

In your docker-compose.yml:

services:

  ...

  # PostGIS database.
  dbservice:
    image: mdillon/postgis:9.6-alpine
    volumes:
      - database:/var/lib/postgresql/data/
    restart: unless-stopped

  # add the pgdumper service
  pgdumper:
    build: ./pgdumper/
    volumes:
      - pgdumps:/pgdumps/
    environment:
      - HOSTNAME=dbservice
    restart: unless-stopped

# volumes definition
volumes:
  ...
  pgdumps:

Set HOSTNAME to the name of your postgres service.

The options are described in the original pg_backup.config file below. All these settings can be set using environment variables.

Additionnaly, you can provide a password (if needed) with the PGPASSWORD env var.

# taken from pg_backup.config

##############################
## POSTGRESQL BACKUP CONFIG ##
##############################
 
# Optional system user to run backups as.  If the user the script is running as doesn't match this
# the script terminates.  Leave blank to skip check.
BACKUP_USER=
 
# Optional hostname to adhere to pg_hba policies.  Will default to "localhost" if none specified.
HOSTNAME=postgres
 
# Optional username to connect to database as.  Will default to "postgres" if none specified.
USERNAME=postgres

# This dir will be created if it doesn't exist.  This must be writable by the user the script is
# running as.
BACKUP_DIR=/pgdumps/

# List of strings to match against in database name, separated by space or comma, for which we only
# wish to keep a backup of the schema, not the data. Any database names which contain any of these
# values will be considered candidates. (e.g. "system_log" will match "dev_system_log_2010-01")
SCHEMA_ONLY_LIST="postgres"
 
# Will produce a custom-format backup if set to "yes"
ENABLE_CUSTOM_BACKUPS=yes
 
# Will produce a gzipped plain-format backup if set to "yes"
ENABLE_PLAIN_BACKUPS=yes
 
 
#### SETTINGS FOR ROTATED BACKUPS ####
 
# Which day to take the weekly backup from (1-7 = Monday-Sunday)
DAY_OF_WEEK_TO_KEEP=5
 
# Number of days to keep daily backups
DAYS_TO_KEEP=7
 
# How many weeks to keep weekly backups
WEEKS_TO_KEEP=5
 
######################################

Changelog

  • 0.1.1 : create the backup directory to avoid failure if it does not exist
  • 0.1 : creates a "latest" dump (so you can restore latest version from a constant path)
  • 0.0.1 : initial release

docker-pgdumper's People

Contributors

olivierdalang avatar

Watchers

James Cloos avatar  avatar  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.