Skip to content

Repository files navigation

docker-database-glacierizer

Docker image for automatic database backups to AWS S3 Glacier with cron-syntax scheduler. Docker Hub

Ready to use simple example how to backup SQL Database with this script

Hints on usage

To use this image you need to set up all of its environment values. If one of its values are missing, empty or of a wrong type, it will print out a message to log to let you know.

EnvironmentDescriptionRequiredDefault
CRONCrontab syntax used to determine when to do a backup. You can use crontab.guru website to get help with cron syntax
START_MANUAL_MANAGEMENT_SERVERWhen set to true, starts a server on specified port to which you can send a http request to manually trigger backup processtrue
MANUAL_MANAGEMENT_PORTProt for manual management server33399
DATABASE_TYPEType of the database you want to backup. Available values [MySQL, PostgreSQL, ClickHouse, MongoDB, Qdrant]
DATABASE_HOSTHostname or IP address to access database
DATABASE_PORTPort to access database. If set to 0 selects a default port for a specified type (3306 for MySQL, 5432 for PostgreSQL, 6333 for Qdrant).0
DATABASE_NAMEName of the database to backup. For Qdrant, leave empty for a full storage backup or provide a collection name for a collection-specific backup.
DATABASE_USERUsername to access database
DATABASE_PASSWORDPassword to access database
QDRANT_API_KEYAPI key to access Qdrant database (if configured)
AUTH_DATABASE_NAMEName of the authentication database. Only used for MongoDBadmin
GLACIER_BUCKET_NAMEName of the S3 bucket where dumps will be stored. If bucket does not exists it will be created
GLACIER_STORAGE_CLASSGlacier storage class that will be used to store uploaded dumps in S3. Available values [instant, flexible, deep]flexible
GLACIER_EXPIRE_AFTERIf set to a value greater than 0 creates a lifecycle rule on whole S3 bucket that will delete an object after set amount of day it was uploaded0
AWS_DEFAULT_REGIONRegion where S3 bucket will be created
AWS_ACCESS_KEY_IDAccess key for AWS account
AWS_SECRET_ACCESS_KEYSecret key for AWS account
SLACK_WEBHOOKIf set it will be sending a message to Slack every time it finishes (successfully or not) dumping database and uploading dump
PROJECT_NAMEUsed as a "header" for slack message. If not set default to machine hostname
LOCAL_DUMPS_COUNTNumber of dumps to retain in the local temporary directory (0-20). If set to 0, all dumps are removed after upload.1
CLICKHOUSE_TIMEOUTTimeout in seconds for ClickHouse backup operations300
DUMP_PATH_DIRPath to the local directory where dump files will be temporarily stored before upload/tmp

Notes

Currently only supports one database per docker container for either PostgreSQL or MySQL databases.

Was only tested on MySQL 5.6 and PostgreSQL 10.11, but should work just fine with other versions as well.

If you enabled server for manual dumping it's better to close the port from outside and use ssh -L option for port forwarding due to lack of security measures for said server.

About

No description, website, or topics provided.

Resources

Stars

6 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages