Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backup concept does not work with docker-compose #129

Open
BOW-el opened this issue Jul 26, 2019 · 0 comments
Open

Backup concept does not work with docker-compose #129

BOW-el opened this issue Jul 26, 2019 · 0 comments

Comments

@BOW-el
Copy link

BOW-el commented Jul 26, 2019

The neat concept to create a point-in-time-backup by specifying REPLICATION_MODE=backup and --volume /srv/docker/backups/postgresql.$(date +%Y%m%d%H%M%S):/var/lib/postgresql \
does not work for a docker-compose file since the volume name cannot be resolved in the yaml syntax.
In order to allow for a declaration of a master and a backup container in a docker-compose file, it would be great if you could add an option, like BACKUP_SCHEDULE, that would persist the backup container continuously and creates a backup at regular time invervals defined by BACKUP_SCHEDULE in subfolders in the volume statically mounted to the container.

In order to illustrate my use case, consider the following docker-compose:

services:
  database:
    restart: always
    image: sameersbn/postgresql:latest
    environment:
      - DB_USER=XXXX
      - DB_NAME=XXXX
      - DB_EXTENSION=pg_trgm
      - USERMAP_UID=1001
      - USERMAP_GID=1001
      - REPLICATION_USER=repluser
    container_name: con_database
    env_file:
      - postgresql-env-secrets.env
    volumes:
      - '/srv/database:/var/lib/postgresql:z'
    networks:
      - net_database
  database_backup:
    restart: always
    image: sameersbn/postgresql:latest
    environment:
      - REPLICATION_MODE=backup
      - REPLICATION_SSLMODE=prefer
      - REPLICATION_HOST=database 
      - REPLICATION_PORT=5432
      - REPLICATION_USER=repluser
      - REPLICATION_PASS=XXXXX
      - BACKUP_SCHEDULE=10m
      - BACKUP_PATTERN=+%Y%m%d%H%M%S
    container_name: con_database_backup
    volumes: 
#  (THIS DOES NOT WORK)
#      - '/srv/database_backup/postgresql.$(date +%Y%m%d%H%M%S):/var
#STATIC FOLDER TO CREATE BACKUPS WITH PATTERN NAME
        - '/srv/database_backup:/var/lib/postgresql:z'      
    networks:
      - net_database    

In this setup, the backup container should ideally persist and create a backup every 10 minutes under a subfolder in the mounted volume /srv/database_backup using BACKUP_PATTERN

Would that be possible?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant