- A. Schulze sca@andreasschulze.de 2015.01.25 16:58:
once setup correctly it works like expected :-)
Good!
how do you separate older postings into the Archive? something like "doveadm search + move ?
Yes basically with move. I'd like to have them archived by year e.g. Public/Archive/Mailing-Lists/Dovecot/2014. Being lazy when it comes to repetitive tasks, I wrote a little script for it. It gives a good idea how to do it (hopefully). Please note that this only has minimal error handling as I'm setting most parameters in the script rather than the shell - butterfingers... No bashism comments please :)
$ cat dovearchive.sh #!/bin/bash # Archive old posts before certain date to 'Public/Archive/Mailbox/Year' # Set basic parameters accordingly: # archive=2011, before_date=$year-mm-dd # source_mailbox_base=Public/Newsletters # dest_mailbox_base=Public/Archive/Newsletters # Actual Mailbox is read from command line set -e archive=2014 let year=$archive+1 before_date=$year-01-01 mailbox_owner=tlx@leuxner.net source_mailbox_base='Public/Mailing-Lists' dest_mailbox_base='Public/Archive/Mailing-Lists' #acl_admin_group=owner acl_admin_group='group=PublicMailboxAdmins' acl_unlock_seq="$acl_admin_group delete expunge insert lookup post read write write-seen write-deleted" acl_lock_seq="$acl_admin_group insert lookup post read write write-seen" acl_lock_archive="$acl_admin_group insert lookup read write write-seen" debug_acl_mailbox_path='path: '
msg_formatted() { echo "$(date "+%b %d %H:%M:%S") $*" }
if [ $# -eq 0 ]; then echo "usage: $0 mailbox" >&2 exit 1 fi
# Mailbox exists? doveadm acl get -u $mailbox_owner "$source_mailbox_base/$1" || { echo 'Mailbox not found.'; exit 1; }
# Create New Archive Mailbox doveadm mailbox create -u $mailbox_owner "$dest_mailbox_base/$1/$archive"
# Modify ACL, expunge mail and revert ACL msg_formatted "[>] Archiving \"$dest_mailbox_base/$1/$archive\""
doveadm acl set -u $mailbox_owner "$source_mailbox_base/$1" $acl_unlock_seq doveadm move -u $mailbox_owner "$dest_mailbox_base/$1/$archive" mailbox "$source_mailbox_base/$1" before $before_date doveadm acl set -u $mailbox_owner "$source_mailbox_base/$1" $acl_lock_seq
# Get actual path of dovecot-acl file and remove it as it is handled by global ACL acl_path=$(doveadm acl debug -u $mailbox_owner "$source_mailbox_base/$1" 2>&1 | sed -n "s/\(.*\)$debug_acl_mailbox_path//p")
[ -f $acl_path/dovecot-acl ] && rm $acl_path/dovecot-acl
msg_formatted '[ Complete ]'