Script to prune mailbox zimbra?



  • Hi,
    I was wondering if someone else has had the same dilemma, so currently i have postfix email server which im moving to zimbra.

    On my postfix server i had this script that would clean 90 days of emails

    #!/bin/bash
     /usr/bin/find /home/in/Maildir/cur -type f -mtime +90 -delete -name "*.mail.mydomain.com:2"
     /usr/bin/find /home/in/Maildir/cur -type f -mtime +90 -delete -name "*.mail.mydomain.com:2,S"
    /usr/bin/find /home/in/Maildir/cur -type f -mtime +90 -delete -name "*.mail.mydomain.com"
    

    and this script to clean the other mailboxes

     #!/bin/bash
    MAILDIRS=$(find /home/*/Maildir/ -maxdepth 0 -type d)
    for basedir in $MAILDIRS; do
      for dir in .Trash .Junk .Spam .Low\ Priority; do
        for dir2 in cur new; do
          [ -e "$basedir/$dir/$dir2" ] && (
            echo "Processing $basedir/$dir/$dir2..."
            find "$basedir/$dir/$dir2/" -type f -mtime +90 -delete
          )
        done
      done
    done
    

    I also saw an option on zimbra about retention policy but i think its not automatic as it needs user permission manually?
    or am i wrong?

    I was looking around but i found a few scripts for zimbra but it deletes amounts of email but not by time

    Thank you



  • You can setup the setting on the Admin GUI and it will be done automatically as below
    2020-01-10_0144.png

    Under Home > Configure > Class of Service → COS → Advanced and scroll down to the Email Retention Policy, it can be per user or per domain.

    https://zimbra.github.io/adminguide/latest/#_managing_features_and_settings_with_a_cos



  • Thank you for the reply, but i only need to purge 2 email boxes of the inbox, i went to the user mailbox on the admin and on advance i found this i check on the purge interval and got this

    [email protected]:/root$ zmprov gacf | grep zimbraMailPurgeSleepInterval
    zimbraMailPurgeSleepInterval: 1m
    

    So my question is if i activate the email message life time to 90 it means that it will purge emails of that email inbox keeping only 90 days of email?

    Thank you

    6b3d2c32-2563-46a3-9da7-a84838033630-image.png



  • @killmasta93 said in Script to prune mailbox zimbra?:

    Thank you for the reply, but i only need to purge 2 email boxes of the inbox, i went to the user mailbox on the admin and on advance i found this i check on the purge interval and got this

    [email protected]:/root$ zmprov gacf | grep zimbraMailPurgeSleepInterval
    zimbraMailPurgeSleepInterval: 1m
    

    So my question is if i activate the email message life time to 90 it means that it will purge emails of that email inbox keeping only 90 days of email?

    Thank you

    6b3d2c32-2563-46a3-9da7-a84838033630-image.png

    Yeah, the mailbox will only keep 90 days worth of email.



  • Thank you currently i put 30 days as wont let me add less to test it out i guess have to wait around a few weeks to test it out thank you again


Log in to reply