Coder Social home page Coder Social logo

elgerm / docker-pgdump-s3 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tozny/docker-pgdump-s3

0.0 1.0 0.0 666 KB

execute pg_dump and stream the output to s3 with a docker container service

License: MIT License

Dockerfile 1.12% JavaScript 97.15% Shell 1.73%

docker-pgdump-s3's Introduction

docker-pgdump-s3

Overview

A docker container that runs pg_dump and streams the output to s3.

It run inside a docker container on a cron schedule that is specified by the CRON_SCHEDULE environment variable.

The original project was designed to run in AWS lambda. Our requirements meant went we needed more than 5 minutes of execution time to run pg_dump. Therefore, the service has been altered to run on a cron schedule.

The service utilizes AWS S3 multi-part uploads & streaming. This means there is no need for large amounts of local storage where the docker container is running, as the data is proxied directly to AWS without being written to disk. This results in a low memory footprint (~50mb) for the running service during backup, and fairly low CPU usage (~5% when testing during dumping).

The architecture looks like:

[Postgres DB] ---> [docker-pgdump-s3] ---> [AWS S3 bucket]

Requirements

  • S3 bucket
  • AWS credentials to push to S3 bucket
  • Postgres host, username, password

Quick Start

docker run -d --env-file=service.env tozny/pgdump-s3

Or with the environment variables spelled out:

docker run -d \
  -e PGPASSWORD=password \
  -e PGDATABASE=mydatabase \
  -e PGUSER=root \
  -e PGHOST=localhost \
  -e S3_BUCKET=muhbucket \
  -e S3_REGION=us-west-2 \
  -e AWS_ACCESS_KEY_ID=AK \
  -e AWS_SECRET_ACCESS_KEY=SK \
  -e PG_PARAMS="-Fp -a" \
  -e BACKUP_EXTENSION=backup \
  -e S3_STORAGE_CLASS=GLACIER \
  -e CRON_SCHEDULE="* * * * *" \
  -e S3_URL="s3-fips.us-west-2.amazonaws.com" \
  # only specify if you want AES encrypted backups, otherwise leave out \
  -e ENCRYPTION_PASSWORD=password \
  tozny/pgdump-s3

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.