Sign inSign up

freinet/autopostgresqlbackup

By freinet

•Updated over 6 years ago

AutoPostgreSQLBackup based on the work of Paulino Padial (TZ setting added)

Image
0

6.7K

freinet/autopostgresqlbackup repository overview

⁠Docker AutoPostgreSQLBackup

AutoPostgreSQLBackup in a docker container

Docker Automated build Docker Build Status Docker image size Docker image version

This docker container uses the autopostgresqlbackup package from ubuntu repos with a minimal modification to make it able to use variables from environment variables, making the configuration through docker model possible. The original source code with modifications is in this repo, also the license GPLv2 has been respected and this repo is under GPLv2.

This container follow the dockerfile good practices⁠.

⁠Installation

docker pull freinet/autopostgresqlbackup

⁠Configuration

⁠Volumes
MOUNTDESCRIPTION
/backupsa directory that contains the crontab files (one or many) with crontab format

⁠Environment variables

NAMEVALUESDEFAULTDESCRIPTION
CRON_LOG_LEVEL1 to 88Level of verbosite. Most verbose is 0, less verbose is 8
CRON_SCHEDULEa valid cron specificationemptyBy default the app uses cron.daily schedule, but you can't crontrol the hour, so, is a ramdon momment during the day. If you want to schedule a fix time to run the backups define this environment variable with a valid cron_schedule.
DBHOSThostnamelocalhostname of the db host to connect.
USERNAMEstringpostgresuser used to connects to the db.
PASSWORDstringemptypassword for the user to connects to the db. Remember doing this you have the password in an environment variable. If you prefer to use Docker Secrets (I recommend this) don't define this env var or leave it blank, and go to the PASSWORD_SECRET environment variable.
PASSWORD_SECRETdocker secret nameemptycontains the name of the secret file where to read the password using docker secrets. Note: if this variable is defined, PASSWORD value will be ignored.
DBNAMESlist of dbnames separated by whitespaceallList of DBNAMES for Daily/Weekly Backup e.g. "DB1 DB2 DB3".
DBEXCLUDElist of dbnames separated by whitespaceemptyList of DBNAMES to EXLUCDE if DBNAMES are set to all
CREATE_DATABASEyes or noyesInclude CREATE DATABASE in backup?
SEPDIRyes or noyesSeparate backup directory and file for each DB?
DOWEEKLY1 to 76Which day do you want weekly backups? (1 to 7 where 1 is Monday)
COMPgzip or bzip2gzipChoose Compression type.
LATESTyes or nonoAdditionally keep a copy of the most recent backup in a seperate directory.
OPTvalid commandline argumentsemptyOPT string for use with pg_dump ( see man pg_dump )
EXTa file extension starts with ..sqlBackup files extension
TZtimezoneUTCSet timezone

Optional specific environment variables:

NAMEVALUESDEFAULTDESCRIPTION
GLOBALS_OBJECTS: pseudo database name used to dump global objects (users, roles, tablespaces). default postgres_globals.
COMMCOMP0 to 90Compress communications between backup server and PostgreSQL server? set compression level from 0 to 9 (0 means no compression)

You need to configure also the script using a configuration file, it's self described so take a look and read the options autopostgresqlbackup⁠

⁠Usage

docker run --name autopostgresqlbackup -v /my/backup/dir:/backups -e DBHOST=mypgbackup -e PASSWORD=mycomplexpassword -v /etc/localtime:/etc/localtime:ro ppadial/autopostgresqlbackup:latest
⁠With docker-compose
version: '3.5'

services:
  autopgbackup:
    image: ppadial/autopostgresqlbackup:latest
    container_name: autopgbackup
    environment:
      - DBHOST = mypgserver
      - PASSWORD_SECRET=posgre-pass
    volumes:
     - /my/backups/dir:/backups
     - /etc/localtime:/etc/localtime:ro
    secrets:
     - posgre-pass

  secrets:
    posgre-pass:
      file: /path/to/file/that/contains/password

⁠Origin

Paulino Padial – @ppadial⁠ – github.com/ppadial

Distributed under the GPLv2 license. See LICENSE⁠ for more information.

https://github.com/ppadial/docker-autopostgresqlbackup⁠

Tag summary

Content type

Image

Digest

Size

98.4 MB

Last updated

over 6 years ago

docker pull freinet/autopostgresqlbackup