From 1038fa3d50bda90377117559a9f685e2e7389d8f Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Sat, 10 Dec 2016 17:40:49 +0100 Subject: dovecot: use Single-Instance Storage for mail attachments. --- roles/IMAP/files/etc/cron.d/doveadm | 3 +++ roles/IMAP/files/etc/dovecot/conf.d/10-mail.conf | 6 +++--- roles/IMAP/tasks/imap.yml | 20 ++++++++++++-------- .../templates/etc/bacula/bacula-dir.conf.j2 | 6 ++++++ 4 files changed, 24 insertions(+), 11 deletions(-) create mode 100644 roles/IMAP/files/etc/cron.d/doveadm diff --git a/roles/IMAP/files/etc/cron.d/doveadm b/roles/IMAP/files/etc/cron.d/doveadm new file mode 100644 index 0000000..1f1f139 --- /dev/null +++ b/roles/IMAP/files/etc/cron.d/doveadm @@ -0,0 +1,3 @@ +MAILTO=root + +7 5 * * * vmail test -x /usr/bin/doveadm && nice -n 19 /usr/bin/doveadm sis deduplicate /home/mail/attachments /home/mail/attachments/queue diff --git a/roles/IMAP/files/etc/dovecot/conf.d/10-mail.conf b/roles/IMAP/files/etc/dovecot/conf.d/10-mail.conf index ab5ceef..2e68df4 100644 --- a/roles/IMAP/files/etc/dovecot/conf.d/10-mail.conf +++ b/roles/IMAP/files/etc/dovecot/conf.d/10-mail.conf @@ -362,7 +362,7 @@ mdbox_preallocate_space = yes # this for now. # Directory root where to store mail attachments. Disabled, if empty. -#mail_attachment_dir = +mail_attachment_dir = /home/mail/attachments # Attachments smaller than this aren't saved externally. It's also possible to # write a plugin to disable saving specific attachments externally. @@ -372,9 +372,9 @@ mdbox_preallocate_space = yes # posix : No SiS done by Dovecot (but this might help FS's own deduplication) # sis posix : SiS with immediate byte-by-byte comparison during saving # sis-queue posix : SiS with delayed comparison and deduplication -#mail_attachment_fs = sis posix +mail_attachment_fs = sis-queue /home/mail/attachments/queue:posix # Hash format to use in attachment filenames. You can add any text and # variables: %{md4}, %{md5}, %{sha1}, %{sha256}, %{sha512}, %{size}. # Variables can be truncated, e.g. %{sha256:80} returns only first 80 bits -#mail_attachment_hash = %{sha1} +mail_attachment_hash = %{sha256} diff --git a/roles/IMAP/tasks/imap.yml b/roles/IMAP/tasks/imap.yml index 51e7694..f4a23e4 100644 --- a/roles/IMAP/tasks/imap.yml +++ b/roles/IMAP/tasks/imap.yml @@ -36,11 +36,21 @@ owner=root group=root mode=0755 -- name: Create /home/mail/virtual - file: path=/home/mail/virtual +- name: Create /home/mail/{virtual,attachments,spamspool} + file: path=/home/mail/{{ item }} state=directory owner=vmail group=vmail mode=0700 + with_items: + - virtual + - attachments + - spamspool + +- name: Create a cronjob for SIS deduplication + copy: src=etc/cron.d/doveadm + dest=/etc/cron.d/doveadm + owner=root group=root + mode=0644 - name: Create virtual mailbox directories file: path=/etc/dovecot/virtual/{{ item }} @@ -64,12 +74,6 @@ - recent - unseen -- name: Create directory /home/mail/spamspool - file: path=/home/mail/spamspool - state=directory - owner=vmail group=vmail - mode=0700 - - name: Create directory /etc/dovecot/ssl file: path=/etc/dovecot/ssl state=directory diff --git a/roles/bacula-dir/templates/etc/bacula/bacula-dir.conf.j2 b/roles/bacula-dir/templates/etc/bacula/bacula-dir.conf.j2 index 046ba01..eb7566b 100644 --- a/roles/bacula-dir/templates/etc/bacula/bacula-dir.conf.j2 +++ b/roles/bacula-dir/templates/etc/bacula/bacula-dir.conf.j2 @@ -102,6 +102,7 @@ Job { Name = {{ hostvars[h].inventory_hostname_short }}-mailboxes Client = {{ hostvars[h].inventory_hostname_short }}-fd JobDefs = DefaultJob + Accurate = no FileSet = Mailboxes Pool = mailboxes-inc Full Backup Pool = mailboxes-full @@ -352,11 +353,16 @@ FileSet { FileSet { Name = Mailboxes Include { + Options { + WildDir = /home/mail/attachments/queue + Exclude = yes + } Options { signature = SHA1 verify = pins1 } File = /home/mail/virtual + File = /home/mail/attachments File = /home/mail/spamspool } } -- cgit v1.2.3