Sign inSign up

nebo15/alpine-postgre-backup

By nebo15

•Updated over 8 years ago

Pghoard Docker container based on Alpine Linux that automates backups for PostgreSQL databases.

Image
2

5.3K

nebo15/alpine-postgre-backup repository overview

⁠Alpine PostgreSQL Backups

This is a minimalistic Docker container based on Alpine Linux with pghoard⁠ backup utility. It can be deployed to your cluster once and will manage backups for all configured PostgreSQL sites.

Container can be started either in backup or restoration mode, which is set by PGHOARD_RESTORE_SITE environment variable. If it's set to a valid host name from PG_HOSTS list, it will restore database to the latest available basebackup.

⁠Installation

Image is available in nebo15/alpine-postgre-backup Docker Hub⁠ repo.

⁠Environment variables
VAR_NAMEDefault ValueDescription
PGHOARD_ACTIVE_BACKUP_MODEnot setCan be either pg_receivexlog or archive_command. If set to pg_receivexlog, pghoard will start up a pg_receivexlog process to be run against the database server. If archive_command is set, we rely on the user setting the correct archive_command in postgresql.conf. You can also set this to the experimental walreceiver mode whereby pghoard will start communicating directly with PostgreSQL through the replication protocol. (Note requires an unreleased version of psycopg2 library).
PGHOARD_BASEBACKUP_COUNT2How many basebackups should be kept around for restoration purposes. The more there are the more diskspace will be used.
PGHOARD_BASEBACKUP_INTERVAL_HOURS24How often to take a new basebackup of a cluster. The shorter the interval, the faster your recovery will be, but the more CPU/IO usage is required from the servers it takes the basebackup from. If set to a null value basebackups are not automatically taken at all.
PG_HOSTSnot setList of PostgreSQL connections URLs separated by ;, eg: postgres://pghoard:secretpassword@host:5432/dbname;postgres://pghoard:secretpassword@other_host:5432/dbname. For each connection new pghoard backup site will be created.
PGHOARD_STATSD_ADDRESSnot setAddress or host on which StatsD server accepts metrics. StatsD collection will be disabled if this variable is not set.
PGHOARD_STATSD_PORT8125Port on which StatsD server accepts metrics.
PGHOARD_STATSD_FORMATdatadogProtocol that is supported by StatsD server: datadog⁠ or telegraf⁠.
PGHOARD_LOG_LEVELINFODetermines log level of pghoard.
PGHOARD_STORAGE_TYPEnot setWhere to store backups? Supported values: local, google, s3, azure, swift.

For restoration:

VAR_NAMEDefault ValueDescription
PGHOARD_RESTORE_SITEnot setHost name of a backed-up database.
PGHOARD_ENCRYPTION_PRIVATE_KEYnot setPrivate key to decrypt your backups. Optional.

Encrypt your backups:

VAR_NAMEDefault ValueDescription
PGHOARD_ENCRYPTION_KEY_IDnot setName of encryption key.
PGHOARD_ENCRYPTION_PUBLIC_KEYnot setPublic key to encrypt your backups.
⁠Local storage
VAR_NAMEDefault ValueDescription
PGHOARD_DIRECTORYnot set
⁠Amazon S3 storage
VAR_NAMEDefault ValueDescription
AWS_ACCESS_KEY_IDnot set
AWS_SECRET_ACCESS_KEYnot set
AWS_DEFAULT_REGIONnot set
AWS_HOSTnot setNot required.
AWS_PORTnot setNot required.
AWS_IS_SECUREnot setNot required.
AWS_BUCKETNAMEnot set
⁠Google Cloud Storage
VAR_NAMEDefault ValueDescription
GCS_PROJECT_IDnot setID of a GCS project.
GCS_BUCKET_NAMEnot setBucket name.
GCS_CREDENTIAL_FILEnot setPath to the JSON credentials file. Generated in IAM -> Service Accounts.
⁠OpenStack Swift storage
VAR_NAMEDefault ValueDescription
OS_USERNAMEnot set
OS_PASSWORDnot set
OS_AUTH_URLnot set
OS_CONTAINER_NAMEnot set
OS_REGION_NAMEnot setNot required.
OS_TENANT_NAMEnot set

⁠StatsD

If PGHOARD_STATSD_ADDRESS environment variable is set, this container will send meaningful metrics about backups:

  • pghoard.compressed_size_ratio - (gauge) backups compression ratio.
  • pghoard.last_upload_age - (gauge) number of seconds since last upload to the storage.
  • pghoard.total_upload_size - (gauge) total upload volume.
  • pghoard.upload_size - (rate) size of uploaded backup.
  • pghoard.xlogs_since_basebackup - (gauge) number of XLogs since last basebackup.

⁠License

See LICENSE.md⁠.

Tag summary

Content type

Image

Digest

Size

65.6 MB

Last updated

over 8 years ago

docker pull nebo15/alpine-postgre-backup