Powered by Blogger.

How To Export/Import Filter on Zimbra Mail Server

Filter is one of many attribute that should be migrate from old Zimbra to the new Zimbra. After previously success migrating Signature from old to the new Zimbra, this is what i do for migrating filter from old to the new Zimbra.
Export (on the old Zimbra)
1.cd /srv/
2.mkdir filter
3.vi export-filter.sh
Fill with the following line
01.#!/bin/bash
02. 
03.clear
04. 
05.echo "Retrieve zimbra user name..."
06. 
07.USERS=`su - zimbra -c 'zmprov -l gaa | sort'`;
08. 
09.for ACCOUNT in $USERS; do
10.NAME=`echo $ACCOUNT`;
11.filter=`su - zimbra -c "zmprov ga $NAME zimbraMailSieveScript" > /tmp/$NAME`
12. 
13.sed -i -e "1d" /tmp/$NAME
14.sed 's/zimbraMailSieveScript: //g' /tmp/$NAME > filter/$NAME
15.rm /tmp/$NAME
16.echo "Export filter for $NAME..."
17.done
18.echo "All filter has been export successfully"
Save and execute the script
1.chmod +x /srv/export-filter.sh
2.sh /srv/export-filter.sh
results of the above script are all file which is located in /srv/filter folder. Copy filter folder (and all files) to the new Zimbra
Import (on the new Zimbra)
Assuming filter folder (from old Zimbra) is placed in /srv/ folder. Make a script for import filter
1.cd /srv/
2.vi import-filter.sh
Fill with the following line
1.for file in /srv/filter/*
2.do
3.StrFilter=`cat "$file"`
4.Acc=`echo $file cut -d "/" -f5`
5.su - zimbra -c "zmprov ma $Acc zimbraMailSieveScript '$StrFilter'"
6.echo "Process filter $Acc"
7.done
8.echo "All filter has been import successfully"
Please wait script until done and check either account who has filter.
Good luck and hopefully useful 😀
    Blogger Comment
    Facebook Comment