Docker Swarm

Configuring Snapshots on Docker Swarm

This content is associated with a legacy version of the Replicated product. For the current Replicated product documentation, see docs.replicated.com.

Snapshots with Docker Swarm

Any volumes holding your application data can be included in snapshots by listing them under the backup section in your config. Replicated will check all nodes in your cluster for volumes with a matching name and include them in your snapshot.

---
# kind: replicated

replicated_api_version: 2.17.0
name: "Swarm"

admin_commands:
  - alias: backup-redis-to-rdb
    command: [redis-cli, bgsave]
    run_type: exec
    service: redis
  - alias: mv-backup-rdb-to-safe-place
    command: [mv, /data/dump.rdb, /backup/dump.rdb]
    run_type: exec
    service: redis

backup:
  enabled: true
  script: |
    #!/bin/sh
    replicated admin backup-redis-to-rdb
    replicated admin mv-backup-rdb-to-safe-place    
  swarm:
    volumes: [ "redis-backup-data" ]

---
# kind: scheduler-swarm
version: "3"

services:
  redis:
    image: redis:3.2-alpine
    ports:
      - "6379"
    volumes:
      - redis-data:/data
      - redis-backup-data:/backup

volumes:
  redis-data:
  redis-backup-data:

Multi-strategy Snapshots with Docker Swarm

Multi-strategy snapshots can also be used with Swarm.

When configuring multi-strategy snapshots, all volumes that will be restored should be included under the same strategy.

...
backup:
  enabled: true
  strategies:
    - name: full
      swarm:
        volumes: [ "redis-backup-data" ]
...