Use bind mounts in sample config (#2035)

* Update docker-compose.yml

* Update faq.md

* chore: remove volume reference

* fix: remove trailing whitespace

* chore: add more verbose description

Co-authored-by: Brennan Kinney <5098581+polarathene@users.noreply.github.com>

* gzip switch added

Not all tar versions do support auto detection of compression.

Co-authored-by: Frederic Werner <20406381+wernerfred@users.noreply.github.com>
Co-authored-by: Brennan Kinney <5098581+polarathene@users.noreply.github.com>
Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
This commit is contained in:
Casper 2021-06-16 13:24:36 +02:00 committed by GitHub
parent 5becce8064
commit b6b0948095
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 12 deletions

View file

@ -17,16 +17,11 @@ services:
- "587:587" # ESMTP (explicit TLS => STARTTLS)
- "993:993" # IMAP4 (implicit TLS)
volumes:
- maildata:/var/mail
- mailstate:/var/mail-state
- maillogs:/var/log/mail
- ./data/maildata:/var/mail
- ./data/mailstate:/var/mail-state
- ./data/maillogs:/var/log/mail
- /etc/localtime:/etc/localtime:ro
- ./config/:/tmp/docker-mailserver/
restart: always
stop_grace_period: 1m
cap_add: [ "NET_ADMIN", "SYS_PTRACE" ]
volumes:
maildata:
mailstate:
maillogs:

View file

@ -54,16 +54,30 @@ Please do not use `CRLF`.
### What about backups?
#### Bind mounts (default)
From the location of your `docker-compose.yml`, create a compressed archive of your `./config` and `./data` folders:
```bash
tar --gzip -cf "backup-$(date +%F).tar.gz" config data
```
Then to restore `./config` and `./data` folders from your backup file:
```bash
tar --gzip -xf backup-date.tar.gz
```
#### Volumes
Assuming that you use `docker-compose` and data volumes, you can backup the configuration, emails and logs like this:
```sh
# create backup
docker run --rm -ti \
-v maildata:/var/mail \
-v mailstate:/var/mail-state \
-v maillogs:/var/logs/mail \
docker run --rm -it \
-v "$PWD/config":/tmp/docker-mailserver \
-v /backup/mail:/backup \
--volumes-from mailserver \
alpine:latest \
tar czf "/backup/mail-$(date +%F).tar.gz" /var/mail /var/mail-state /var/logs/mail /tmp/docker-mailserver