-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-volume-backup.yaml
More file actions
56 lines (51 loc) · 1.72 KB
/
Copy pathdocker-volume-backup.yaml
File metadata and controls
56 lines (51 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
name: docker-volume-backup
description: >
Back up a Docker volume to S3 on a daily schedule.
Compresses the volume contents, uploads to S3, and
sends a Slack alert on success or failure.
triggers:
- type: cron
schedule: "0 2 * * *"
steps:
- name: backup-volume
action: docker/run
credential: my-docker
timeout: "10m"
params:
image: alpine
cmd: ["tar", "-czf", "/mantle/artifacts/backup.tar.gz", "-C", "/data", "."]
mounts:
- source: "my-app-data"
target: "/data"
readonly: true
memory: "256m"
remove: true
artifacts:
- path: /mantle/artifacts/backup.tar.gz
name: backup-archive
- name: upload-to-s3
action: s3/put
credential: aws-prod
timeout: "5m"
params:
bucket: my-backups
key: "volumes/my-app-data/{{ date }}/backup.tar.gz"
content: "{{ artifacts['backup-archive'].url }}"
content_type: "application/gzip"
- name: notify-success
action: slack/send
credential: slack-token
if: "steps['upload-to-s3'].error == null && steps['upload-to-s3'].output.size > 0"
params:
channel: "#ops-alerts"
text: "Volume backup completed — {{ artifacts['backup-archive'].size }} bytes uploaded to s3://my-backups/volumes/my-app-data/"
# NOTE: notify-failure requires continue_on_error support (see issue #29).
# Without it, the engine halts on the first failed step and this step
# will not execute. This is included to show the intended pattern.
- name: notify-failure
action: slack/send
credential: slack-token
if: "steps['upload-to-s3'].error != null || steps['backup-volume'].error != null"
params:
channel: "#ops-alerts"
text: "Volume backup FAILED"