From b7b2de9a82b2dca3aa730fccec03623682a3329d Mon Sep 17 00:00:00 2001 From: Davide Principi Date: Thu, 31 Oct 2024 17:04:32 +0100 Subject: [PATCH] Save the IMAP mailbox list in the backup The mailbox list is needed to quickly find an IMAP folder path inside a given backup snapshot. Maildir path-encoding format can be obtained with the "doveadm mailbox path" command. --- imageroot/bin/module-cleanup-state | 1 + imageroot/bin/module-dump-state | 5 +++++ imageroot/etc/state-include.conf | 1 + 3 files changed, 7 insertions(+) diff --git a/imageroot/bin/module-cleanup-state b/imageroot/bin/module-cleanup-state index a7637591..af98e8e0 100755 --- a/imageroot/bin/module-cleanup-state +++ b/imageroot/bin/module-cleanup-state @@ -7,4 +7,5 @@ echo "Cleaning up Mail state:" rm -vf pcdb-dump.sql +rm -vf maildir-dump.lst rm -vf *.is-enabled diff --git a/imageroot/bin/module-dump-state b/imageroot/bin/module-dump-state index 92f832a2..25d90e12 100755 --- a/imageroot/bin/module-dump-state +++ b/imageroot/bin/module-dump-state @@ -7,6 +7,11 @@ echo "Dumping Mail state to disk:" podman exec postfix sqlite3 /srv/pcdb.sqlite .dump > pcdb-dump.sql +echo "Saving Maildir IMAP folder index:" +podman exec -i dovecot ash -s >maildir-dump.lst <<'EOF' +doveadm -f tab mailbox list -A | tail -n +2 | grep -v -E $'\t''(Shared|Public)(/|$)' +EOF +echo "Saving service status:" for unit in clamav.service freshclam.timer; do systemctl --user is-enabled "${unit}" > "${unit}".is-enabled || : # ignore exit code done diff --git a/imageroot/etc/state-include.conf b/imageroot/etc/state-include.conf index c82cd2f3..ea92b3e7 100644 --- a/imageroot/etc/state-include.conf +++ b/imageroot/etc/state-include.conf @@ -4,6 +4,7 @@ # Restic --files-from: https://restic.readthedocs.io/en/stable/040_backup.html#including-files # state/pcdb-dump.sql +state/maildir-dump.lst state/dovecot.env state/rspamd.env state/*.is-enabled