Backup script improved (#1912)

This commit is contained in:
Casper 2021-04-16 11:26:51 +02:00 committed by GitHub
parent e1178459eb
commit 6fbd1967d1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -54,17 +54,21 @@ Please do not use `CRLF`.
### What about backups? ### What about backups?
Assuming that you use `docker-compose` and a data volumes, you can backup your user mails like this: Assuming that you use `docker-compose` and data volumes, you can backup the configuration, emails and logs like this:
```sh ```sh
# create backup
docker run --rm -ti \ docker run --rm -ti \
-v maildata:/var/mail \ -v maildata:/var/mail \
-v mailstate:/var/mail-state \ -v mailstate:/var/mail-state \
-v maillogs:/var/logs/mail \
-v "$PWD/config":/tmp/docker-mailserver \
-v /backup/mail:/backup \ -v /backup/mail:/backup \
alpine:3.2 \ alpine:latest \
tar czf "/backup/mail-$(date +%y%m%d-%H%M%S).tgz" /var/mail /var/mail-state tar czf "/backup/mail-$(date +%F).tar.gz" /var/mail /var/mail-state /var/logs/mail /tmp/docker-mailserver
find /backup/mail -type f -mtime +30 -exec rm -f {} \; # delete backups older than 30 days
find /backup/mail -type f -mtime +30 -delete
``` ```
### What about `mail-state` folder? ### What about `mail-state` folder?