jareware/docker-volume-backup

Add option to define labels per specific stack

stanczakp opened this issue · 3 comments

I think it is a good idea to add possibility to define labels per specific stack. At the moment when multiple stacks are suing the exec-pre-backup and exec-post-backup labels then all commands are executed. For example lets say we have this two stacks:

mattermost:

version: "3.3"
...
services:
...
  db:
    image: postgres
    restart: unless-stopped
    volumes:
      - pgdata:/var/lib/postgresql/data
      - tmp:/tmp/
    environment:
      - POSTGRES_USER=mmuser
      - POSTGRES_PASSWORD=password
      - POSTGRES_DB=mattermost
    networks:
      - internal
    labels:
      - docker-volume-backup.exec-pre-backup=pg_dumpall -U mmuser -f /tmp/mattermost.dump
      - docker-volume-backup.exec-post-backup=rm -fv /tmp/mattermost.dump
...

sentry:

version: "3.3"
...
services:
...
  postgres:
    image: postgres
    volumes:
      - pgdata:/var/lib/postgresql/data
      - tmp:/tmp/
    restart: unless-stopped
    environment:
      - POSTGRES_USER: sentry
      - POSTGRES_PASSWORD: password
    networks:
      - internal
    labels:
      - docker-volume-backup.exec-pre-backup=pg_dumpall -U sentry -f /tmp/sentry.dump
      - docker-volume-backup.exec-post-backup=rm -fv /tmp/sentry.dump
...

running the ./backup.sh in the mattermost stack gives following output:

[INFO] Backup starting
...

[INFO] Pre-exec command: 7f23fe144d86 pg_dumpall -U sentry -f /tmp/sentry.dump


[INFO] Pre-exec command: 95a3c4f1ed92 pg_dumpall -U mmuser -f /tmp/mattermost.dump


[INFO] Creating backup

tar: Removing leading `/' from member names
...

which makes two dump of databases, but it should run only the mattermost db backup.

Would your use case be served by #14?

Yes! Perfect!

This is now available as part of the latest release!