-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
87 lines (78 loc) · 2.23 KB
/
docker-compose.yml
File metadata and controls
87 lines (78 loc) · 2.23 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
version: '2'
services:
isync:
image: theohbrothers/docker-isync:1.4.4-restic
environment:
- RESTIC_REPOSITORY=/backup
- RESTIC_PASSWORD=test
volumes:
- mail:/mail
- backup:/backup
- restore:/restore
- /root/.cache/restic # Restic cache. See: https://restic.readthedocs.io/en/stable/manual_rest.html#caching
networks:
- default
restart: unless-stopped
stop_signal: SIGKILL
entrypoint:
- /bin/sh
command:
- -c
- |
set -eu
echo "Creating /mbsyncrc"
cat - > /mbsyncrc <<'EOF'
IMAPStore example-remote
Host imap.example.com
User test@example.com
Pass test
AuthMechs LOGIN
SSLType IMAPS
# Limit the number of simultaneous IMAP commands
PipelineDepth 30
MaildirStore example-local
SubFolders Verbatim
# The trailing '/' is important for Path
Path /mail/
Inbox /mail/INBOX
Channel example
Far :example-remote:
Near :example-local:
Patterns *
Create Near
Expunge Near
SyncState *
Sync Pull
EOF
echo 'Creating /backup.sh'
touch /backup.sh && chmod 700 /backup.sh
cat - > /backup.sh <<'EOF'
#!/bin/sh
set -eux
restic init || true
restic snapshots
restic check -v
restic prune -v
restic forget --prune -v --keep-within '365d'
restic backup -v --tag cron /mail
EOF
echo "Creating /notify.sh"
touch /notify.sh && chmod 700 /notify.sh
cat - > /notify.sh <<'EOF'
echo "Sending notification"
curl -o /dev/null -s -w "%{http_code}\n" -X POST https://example.com/?message=$${1:-empty}
EOF
# Run at 00:00 daily. To customize the cron schedule, use https://crontab.guru
echo "Creating crontab"
crontab - <<'EOF'
0 0 * * * /sync && /backup.sh && /notify.sh success || /notify.sh failed
EOF
crontab -l
echo "Running crond"
exec crond -f
networks:
default:
volumes:
mail:
backup:
restore: