Migrasi email account dan data dari postfixadmin mysql ke zimbra

| Thursday, October 18, 2012

Hal yang perlu dilakukan untuk migrasi tentu saja instalasi zimbra mailserver. Saya menggunakan OS Ubuntu 10 LTS dgn ZCS 7.2 Langkah berikutnya kurang lebih sbb :
1. List semua domain yg ada pada mailserver lama dan tambahkan domain ke zimbra melalui zimbra admin https://webmai.domain.ltd:7071. Klik pada panel kiri menu configuration klik domain. Klik new tambahkan domain email di server lama klik finish.
2. Eksport email account dari mailserver lama
3. Import email account ke server zimbra
4. Pindahkan data email dari server lama ke server zimbra.

Detailnya sbb : Point 1 saya kira sudah jelas, point2 selanjutnya penjelasannya sbb :

2. Eksport email account dari mailserver lama
Gunakan script php berikut berikut, sesuaikan login dan nama db email. Simpan dgn nama misalnya eksport.php dan jalankan dgn perintah php eksport.php jika berhasil maka akan file exported.sh akan digenerate.

<?php
/////////////////////////////////////////////////////////
$user="Your_mysql_login";
$pass="Your_mysql_pass";
$base="Your_mysql_database";
$tabl="Your_Table_mailbox"; //table
$file="exported.sh";

/////////////////////////////////////////////////////////
echo "Usage: as "zimbra" user on destination server:n";
echo "# sh ./exported.shnn";
echo "";

$mydb = mysql_connect('localhost',$user, $pass) or die ('Error of connection with server');
mysql_select_db($base);
mysql_query("SET CHARACTER SET utf8");
mysql_query("SET NAMES utf8");

$query = "SELECT username,password,name,maildir,quota,domain FROM ".$tabl;
$dane = mysql_query($query) or die ('Error during query for bazy1'.mysql_error());

$handle = fopen($file, "w");

while ($row = mysql_fetch_array($dane, MYSQL_NUM))
{
    $StringData = "zmprov ca ".$row[0]." dsfs123hsdyfgbsdgfbsd displayName '".$row[2]."'n";
    fwrite($handle, $StringData);
    $StringData = "zmprov ma ".$row[0]." userPassword '{crypt}".$row[1]."'"."n";
    fwrite($handle, $StringData);
}
?>

3. Import email account ke server zimbra
Copy file exported.sh ke mailserver zimbra, ubah owner filenya jadi milik zimbra dan beri hak akses eksekusi (chmod), ketik : # su - zimbra $ ./home/aku/exported.sh Tunggu sampai proses selesai dan coba cek pada halaman zimbra admin, apakah account sudah masuk atau belum.

4. Pindahkan data email dari server lama ke server zimbra.
Pada mailserver lama email disimpan pada directory /usr/local/virtual. Gunakan perintah scp di server zimbra untuk mengambil semua file.
# cd /usr/local
# scp -r -P 22 root@ipserverlama:/usr/local/virtual .
Tunggu sampai selesai.
Format dari file email sbb /usr/local/virtual/nmdomain/username/...

Setelah selesai proses pengambilan email lewat scp, buat sebuah file dgn nama convertmail.sh yg isinya script sbb :
 
#!/bin/bash

# Postfix virtual transport -> Zimbra mailbox migration
# written by NERvOus (http://www.nervous.it) - 2009-12-25, Modified By Gigih Forda Nama 2011

# base folder where msgs will be imported
BFOLDER="Arsip-Mail"
ZMMBOX="/opt/zimbra/bin/zmmailbox"
BDIR=$(pwd)

echo You must run $0 from inside /var/mail/virtual directory
echo $0 expects to find the mailboxes in the current path!
echo The structure of maildirs must be as follows:
echo
echo "domain/username/{cur|new|tmp}"
echo "domain/username/subfolder1/{cur|new|tmp}"
echo "domain/username/subfolder2/{cur|new|tmp}"
echo ...
echo
echo All folders will be stored in a subfolder called $BFOLDER
echo The hierarchy of subfolders will be maintained under $BFOLDER.
echo
echo Press Enter to start, CTRL+C to abort.
read

# handle folders with a space inside, they are more common than you may
# think
IFS='
'
for p in $(find . -type d -name cur); do
        DOMAIN=`echo $p | cut -d'/' -f2`
        UNAME=`echo $p | cut -d'/' -f3`
        DIRNAME=`echo $p | cut -d'/' -f4`
        # this may fail, if folder already exists. Who cares. Ignore the
        # error.
        echo createFolder /$BFOLDER | $ZMMBOX -z -m $UNAME@$DOMAIN
        if [ "$DIRNAME" == "cur" ]; then
                echo Importing INBOX folder for $UNAME@$DOMAIN from $BDIR/$DOMAIN/$UNAME/ 1>&2
                # we are importing the top level folder
                echo addMessage /$BFOLDER $BDIR/$DOMAIN/$UNAME/cur | $ZMMBOX -z -m $UNAME@$DOMAIN
                echo addMessage /$BFOLDER $BDIR/$DOMAIN/$UNAME/new | $ZMMBOX -z -m $UNAME@$DOMAIN
        else
                DIRNAME=$(echo $DIRNAME | sed -e 's//cur$//')
                echo Importing folder $DIRNAME for $UNAME@$DOMAIN from $BDIR/$DOMAIN/$UNAME/$DIRNAME 1>&2
                echo createFolder '/$BFOLDER/$DIRNAME' | $ZMMBOX -z -m $UNAME@$DOMAIN
                echo addMessage '/$BFOLDER/$DIRNAME' '$BDIR/$DOMAIN/$UNAME/$DIRNAME/cur' | $ZMMBOX -z -m $UNAME@$DOMAIN
                echo addMessage '/$BFOLDER/$DIRNAME' '$BDIR/$DOMAIN/$UNAME/$DIRNAME/new' | $ZMMBOX -z -m $UNAME@$DOMAIN
        fi
done

Tunggu hingga proses selesai, dan coba login ke account anda di mailserver zimbra.
Script taken from : http://staff.unila.ac.id/gigih/2011/08/04/mail-migration-from-postfix-mysql-to-zimbraldap-backend-again/

8 komentar:

Anonymous said...

replica gucci bags replica gucci bags replica gucci bags [url=http://www.gucci--bags.com/]Gucci bags[/url] www.gucci--bags.com
ugg boots purchase ugg boots sale ugg boots traffic [url=http://www.ugg--bootssale.com/]genuine ugg boots[/url] www.ugg--bootssale.com
spyder jackets spyder ski jackets spyder jackets [url=http://www.spyder--jackets.com/]spyder jackets[/url] www.spyder--jackets.com
replica hermes hermes bags replica hermes bags [url=http://www.replica--hermes.com/]replica hermes[/url] www.replica--hermes.com
replica chanel bags replica chanel bags replica chanel [url=http://www.replica--chanel.com/]chanel bags[/url] www.replica--chanel.com

Anonymous said...

spyder ski jackets spyder jackets spyder jackets [url=http://www.spyder--jackets.com/]spyder jackets[/url] www.spyder--jackets.com
ugg boots sale ugg boots sale ugg boots traffic [url=http://www.ugg--bootssale.com/]ugg boots sale[/url] www.ugg--bootssale.com
replica gucci bags Gucci bags replica gucci bags [url=http://www.gucci--bags.com/]Gucci bags[/url] www.gucci--bags.com
hermes bags replica hermes bags replica hermes [url=http://www.replica--hermes.com/]replica hermes[/url] www.replica--hermes.com
replica chanel bags chanel bags chanel bags [url=http://www.replica--chanel.com/]replica chanel[/url] www.replica--chanel.com

Anonymous said...

hermes bags hermes bags replica hermes bags [url=http://www.replica--hermes.com/]replica hermes bags[/url] www.replica--hermes.com
Gucci bags replica gucci bags replica gucci bags [url=http://www.gucci--bags.com/]Gucci bags[/url] www.gucci--bags.com
ugg boots rummage sale ugg boots sale ugg boots sale [url=http://www.ugg--bootssale.com/]ugg boots sale[/url] www.ugg--bootssale.com
spyder jackets spyder jackets spyder ski jackets [url=http://www.spyder--jackets.com/]spyder ski jackets[/url] www.spyder--jackets.com
chanel bags replica chanel bags replica chanel [url=http://www.replica--chanel.com/]chanel bags[/url] www.replica--chanel.com

Anonymous said...

If we check out the word the word appreciate, not only in relation to its a loving romance using an additional, although as being a sensing that is definitely engendered if you have miltchmonkey a more rewarding partnership with yourself very - as well as being a sensation of larger unity with your loved ones or simply human beings ( blank ) therefore it turns into even more clear that every any individual needs in daily life is usually enjoy.

Anonymous said...

Thank you a bunch for sharing this with all folks you actually know what you are speaking about!
Bookmarked. Kindly also seek advice from my web site =).
We could have a hyperlink exchange agreement among us

Stop by my blog post; bowie love; isaiasvllh.bravejournal.com,

Anonymous said...

Hello there! Would you mind if I share your blog with my facebook group?
There's a lot of folks that I think would really enjoy your content.
Please let me know. Thanks

Also visit my web page - my plumber Chandler

Anonymous said...

The chemical tests and analysis of the ingredients
and their blend takes time. The ingredients of the pill contribute to the stimulant properties of the Fastin weight loss pill from Hi-Tech.

Including diuretic in daily diet schedule is one of the best recommended natural remedies to reduce fat accumulation in body.


Also visit my blog; weight loss pills garcinia cambogia

Anonymous said...

I know this web site provides quality based articles or reviews and extra stuff, is there any other website which provides these
data in quality?

Also visit my blog post PTCSmarty