capnis fd83ad1ed3 Add support for docker secrets
Check if password file ENV variable POSTGRES_PASSWORD_FILE is set (for use with docker secrets, point this to /run/secrets/<name of secret>). If it is not set, fallback to POSTGRES_PASSWORD ENV variable.
2018-06-30 11:15:58 +03:00
2018-06-30 11:15:58 +03:00
2018-06-30 10:59:06 +03:00
2016-10-28 17:20:30 +02:00

postgres-backup-local

Backup PostgresSQL to local filesystem with periodic backups and rotate backups. Based on schickling/postgres-backup-s3.

Usage

Docker:

$ docker run -e POSTGRES_HOST=postgres -e POSTGRES_DB=dbname -e POSTGRES_USER=user -e POSTGRES_PASSWORD=password  prodrigestivill/postgres-backup-local

Docker Compose:

version: '2'
services:
    postgres:
        image: postgres
        restart: always
        environment:
            - POSTGRES_DB=database
            - POSTGRES_USER=username
            - POSTGRES_PASSWORD=password
    pgbackups:
        image: prodrigestivill/postgres-backup-local
        restart: always
        volumes:
            - /var/opt/pgbackups:/backups
        links:
            - postgres
        depends_on:
            - postgres
        environment:
            - POSTGRES_HOST=postgres
            - POSTGRES_DB=database
            - POSTGRES_USER=username
            - POSTGRES_PASSWORD=password
            - POSTGRES_EXTRA_OPTS=-Z9 --schema=public --blobs
            - SCHEDULE=@daily
            - BACKUP_KEEP_DAYS=7
            - BACKUP_KEEP_WEEKS=4
            - BACKUP_KEEP_MONTHS=6

Manual Backups

By default it makes daily backups but you can start a manual one by running the command /backup.sh.

Example running only manual backup on Docker:

$ docker run -e POSTGRES_HOST=postgres -e POSTGRES_DB=dbname -e POSTGRES_USER=user -e POSTGRES_PASSWORD=password  prodrigestivill/postgres-backup-local /backup.sh

Automatic Periodic Backups

You can change the SCHEDULE environment variable like -e SCHEDULE="@daily" to change its default frequency, by default is daily.

More information about the scheduling can be found here.

Folders daily, weekly and monthly are created and populated using hard links to save disk space.

S
Description
Languages
Shell 57.9%
HCL 24%
Dockerfile 18.1%