Database Backup solution for PostgreSQL Database using pg_dump
3.2K
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.
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_URLAWS_ACCESS_KEY_IDAWS_SECRET_ACCESS_KEYARCHIVE_PASSWORDDUMP_FILE_NAMEDB_DUMP_INTERVAL e.g. HOURLY or WEEKLYFor dumping PostgreSQL, define the following:
PG_USERPG_HOSTNAMEPG_DATABASEPG_PASSWORDand for dumping MySQL, define the following:
MYSQL_USERMYSQL_HOSTMYSQL_DATABASESMYSQL_PASSWORDand 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.
Content type
Image
Digest
Size
106 MB
Last updated
over 7 years ago
docker pull ambientinnovation/db_dump