How to transfer rules/filters from one zimbra account to another

May 28th, 2014 | By | Category: Internet, Linux / Freebsd

Well it would appear that the vast majority of links and literature on this subject is outdated and no longer working although it’s not terribly broken it just needs a slight tweak which I’ll post below.  A big thanks to the guys over here: http://www.spheron1.co.uk/2011/06/27/zimbra-mailbox-importexport-and-migration-of-e-mail-filter-rules/ for having the only working solution i found

 

So first you want to export your mail rules from user A by doing this:

zmprov ga user@test.com zimbraMailSieveScript > /opt/backup/xferMailFilters.sh

now you need to import them into another user so go and edit this new mailFilters.sieve file and change the top 2 lines from this

*NOTE: IF YOU ARE COPYING AND PASTING DIRECTLY FROM THIS PAGE YOU WILL HAVE TO MANUALLY REPLACE TO STUPID ASS WORDPRESS SINGLE QUOTES WITH A PROPER ONE AS IT WILL COMPLETELY BREAK YOUR SCRIPT.

#Name user@test.com

zimbraMailSieveScript: require [“fileinto”, “reject”, “tag”, “flag”];

to this

#!/bin/bash

if [[ $1 ]];

then

zmprov ma $1 zimbraMailSieveScript ‘require [“fileinto”, “reject”, “tag”, “flag”];

 

and add this to the very end of the file

else

echo “You forgot to enter a user – Syntax: xferMailFilters.sh user@whatever.com”

fi

 

chmod your new script to 755 or add a +x to it and then run it with the username you want to xfer these files over to as your first variable.  You can use this logic and add onto this to make a script that will export from one user($1) and xfer to another ($2) but that’s out side of what I need right now so I’ll leave that one up to you 🙂

Tags: , , ,

5 Comments to “How to transfer rules/filters from one zimbra account to another”

  1. Edward Dore says:

    You’re welcome, glad to hear that my blog post was helpful to someone 🙂

  2. admin says:

    Truly, I used my little filter xfer script just last week!

  3. Ben says:

    Thanks for this little how to. Exactly what i was looking for. One thing, could you give an example of how you would run the script as a different user? As a zimbra admin newbie I cant quite get the syntax right and an example of running the script would go a long way 🙂

  4. Edward Dore says:

    Hi Ben, if you take a look at the post on my site (the spheron1.co.uk link) then you should be able to use that to specify the user when importing.

  5. Not Me says:

    Used this today. Had hopes it would work nicely. Perhaps I was just pushing a little too hard with 40+ rules.

    In the process of migrating a home Zimbra setup from Ubuntu 14.04 w/ Zimbra 8.0.6 to Ubuntu 16.04 w/Zimbra 8.8.9. Only 10 users, so not a big deal.

    This was the last step in the manual migration. Doing system upgrades had failed terribly, so I decided that starting with a fresh Zimbra on a new box (KVM VM) would be best.

    None of the filters transferred, at least they aren’t showing up inside the Zimbra web-GUI. Before I manually created a filter, there were lots of SOAP error popups. Filters and tags are really the only reason I use the web-GUI. Prefer a fat email client myself.

    BTW, if you get the account data for each account using
    $ zmprov ga notme@domain.com
    then the sieve rules are included inside there. Many of the attributes in that output are handy for modifying new accounts to be just like they were on the old system, though many can only be set, it appears, using either LDAP directly or the Zimbra webGUI, not zmprov ma.

    While I’m at it, with v8.x and later versions of Zimbra, someone decided that having data.mdb (an LDAP DB) allocated as a sparse file would be slick. This totally screws up most backup tools and, at best, requires special handling if you use rsync, gnutar, or cp. Look up the specific options those commands need to handle sparse files. It isn’t automatic. The major backup tools, rdiff-backup, duplicity, do not seem to handle sparse files correctly, directly. On disk, using ‘du’ to see the truth, is 5MB, but ‘ls’ reports 25GB. As a long-term maintenance programmer, I have this to say to the person/team who decided this was smart/slick/cool/Kewl. YOU SUCK!

    I feel better now.

    And I get to manually create the sieve rules again. Appreciate the attempt at sharing a solution. There’s a reason we all choose to use Zimbra, but the added complexity is a necessary by-product for all those features, unfortunately.

Leave a Comment