ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Script to prune mailbox zimbra?

    Scheduled Pinned Locked Moved IT Discussion
    5 Posts 2 Posters 1.3k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • K
      killmasta93
      last edited by

      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

      1 Reply Last reply Reply Quote 1
      • dbeatoD
        dbeato
        last edited by

        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

        1 Reply Last reply Reply Quote 0
        • K
          killmasta93
          last edited by

          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

          zimbra@mail:/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

          dbeatoD 1 Reply Last reply Reply Quote 0
          • dbeatoD
            dbeato @killmasta93
            last edited by

            @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

            zimbra@mail:/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.

            1 Reply Last reply Reply Quote 0
            • K
              killmasta93
              last edited by

              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

              1 Reply Last reply Reply Quote 0
              • 1 / 1
              • First post
                Last post