Sign inSign up

ambientinnovation/db_dump

By ambientinnovation

Updated over 7 years ago

Database Backup solution for PostgreSQL Database using pg_dump

Image
0

3.2K

ambientinnovation/db_dump repository overview

Database Backup Solution

Database Backup solution for PostgreSQL/MySQL Databases using pg_dump and mysqldump for SQL Dumping and Uploading them to S3 Bucket archived and encrypted with a password.

Usage

First you need to build the Docker Image using the following command: docker build . -t db_dump:v1.0.0 -f Dockerfile, Also You can pull the image directly from Ambient Innovation DockerHub Account: ambientinnovation/db_dump

Then, you need to define the required environment variables:

  • AWS_BUCKET_URL
  • AWS_ACCESS_KEY_ID
  • AWS_SECRET_ACCESS_KEY
  • ARCHIVE_PASSWORD
  • DUMP_FILE_NAME
  • DB_DUMP_INTERVAL e.g. HOURLY or WEEKLY

For dumping PostgreSQL, define the following:

  • PG_USER
  • PG_HOSTNAME
  • PG_DATABASE
  • PG_PASSWORD

and for dumping MySQL, define the following:

  • MYSQL_USER
  • MYSQL_HOST
  • MYSQL_DATABASES
  • MYSQL_PASSWORD

and finally you run the docker container for PostgreSQL using the following:

docker run -it --rm \
 -e PG_USER=database-user \
 -e PG_HOSTNAME=database-host \
 -e PG_DATABASE=database-name \
 -e PG_PASSWORD=database-password \
 -e AWS_BUCKET_URL=s3-bucket-url \
 -e AWS_ACCESS_KEY_ID=AKIAJ*********** \
 -e AWS_SECRET_ACCESS_KEY=Yk2****************************** \
 -e ARCHIVE_PASSWORD=my-secret-password \
 -e DUMP_FILE_NAME=dump-file-name \
 -e DB_DUMP_INTERVAL=HOURLY \
 db_dump:latest postgresql

and for MySQL using the following:

docker run -it --rm \
 -e MYSQL_USER=database-user \
 -e MYSQL_HOST=database-host \
 -e MYSQL_DATABASES="database-1 database-2" \
 -e MYSQL_PASSWORD=database-password \
 -e AWS_BUCKET_URL=s3-bucket-url \
 -e AWS_ACCESS_KEY_ID=AKIAJ*********** \
 -e AWS_SECRET_ACCESS_KEY=Yk2****************************** \
 -e ARCHIVE_PASSWORD=my-secret-password \
 -e DUMP_FILE_NAME=dump-file-name \
 -e DB_DUMP_INTERVAL=HOURLY \
 db_dump:latest mysql

To decrypt the backup/archive run openssl enc -aes-256-cbc -d -in name.tar.gz.enc | tar xz.

Tag summary

Content type

Image

Digest

Size

106 MB

Last updated

over 7 years ago

docker pull ambientinnovation/db_dump