This manual is deprecated. Please visit for the latest documentation.


From Group-Office Groupware and CRM Documentation
Jump to: navigation, search

There are various tools for Migration. You can use ActiveSync or SyncML to synchronize the contacts and calendars or you can import calendar *.ics and CSV file for contacts.

Migrate IMAP accounts with a CSV file

To migrate users and e-mail through IMAP you can use the script below. You can use it to migrate from Exchange or any other server that supports IMAP. You need to create a CSV file with this format:

"Group in GO 0","Email address 1","First name 2","Middle name 3","Last name 4","Password 5","GroupOffice User name 6"

Then you need to adjust the variables at the top of the script and run it.


 * Copyright Intermesh
 * This file is part of Group-Office. You should have received a copy of the
 * Group-Office license along with Group-Office. See the file /LICENSE.TXT
 * If you have questions write an e-mail to
 * @version $Id: imapsync.php 4569 2010-04-13 08:27:54Z mschering $
 * @copyright Copyright Intermesh
 * @author Merijn Schering <>

 * This script can be used to create users in Group-Office with a CSV file
 * and migrate the mail through IMAP.
 * This only works if the postfixadmin module runs on the same installation
 * where the new Group-Office users will be created.
 * The script was written for version 3.5.9

//the domain for the mail

//the new mail host
$local_host = 'localhost';

//the old mail host
$remote_host = '';

//the path to the imapsync program
$imapsync = '/usr/bin/imapsync';

//CSV file in format:
//"Group in GO 0","Email address 1","First name 2","Middle name 3","Last name 4","Password 5","GroupOffice User name 6"

//end of variables section.

//otherwise log module will log all items as added.
define('NOLOG', true);

if (isset($argv[1])) {
	define('CONFIG_FILE', $argv[1]);


$postfixadmin = new postfixadmin();

$e = new email();

//make sure e-mail domain exists in database
$domain = $postfixadmin->get_domain_by_domain($maildomain);


$fp = fopen($csv_file, "r");
if (!$fp) {
	die('Could not read CSV file');

//headings, skip one row
$record = fgetcsv($fp, 4096, ',', '"');

while ($record = fgetcsv($fp, 4096, ',', '"')) {

	$remote_user = $record[1];
	$remote_pass = $record[5];
	$groupoffice_user = $record[6];
	$email = $record[1];

	//Check if the user exists in Group-Office and if it doesn't create it.
	$user = $GO_USERS->get_user_by_username($groupoffice_user);

		$group = $GO_GROUPS->get_group_by_name($record[0]);
			$group_id=$GO_GROUPS->add_group(1, $record[0]);

		$user_id = $GO_USERS->add_user($user, array($group_id),array($GO_CONFIG->group_everyone,$group_id));
		$user_id = $user['id'];

	//Create a mailbox in postfixadmin
	$mailbox = $postfixadmin->get_mailbox_by_username($pa_user);
		$mailbox_id= $postfixadmin->add_mailbox($mailbox);





	//create an e-mail account for the user
	$account = $e->get_account_by_username($pa_user, $user_id);
		$account['mbroot'] = '';
		$account['use_ssl'] = 0;



	echo "Syncing " . $record[0] . "\n\n";

	//--skipsize --useheader Message-Id

	$cmd = $imapsync . ' --syncinternaldates --authmech1 LOGIN --authmech2 LOGIN ' .
					'--host1="' . $remote_host . '" --user1="' . $pa_user . '" --password1="' . $remote_pass . '" ' .
					'--user2="' . $remote_user . '" --host2="' . $local_host . '" --password2="' . $remote_pass . '"';

	echo $cmd . "\n\n";


Convert E-mail MSG files to EML files

Group-Office can display EML e-mails but not MSG files. So if you have MSG files you need to convert them. We used a perl script and a bash script to convert them all. You can find the tutorial here:

Migrate an e-mail domain from one Group-Office to another

You might have a need to transfer all mailboxes and aliases to another mailserver. If both mailservers run on the Group-Office mailserver solution with versiopn 3.6 or higher this is very easy. On the old server run:

php /usr/share/groupoffice-mailserver/export_domain.php

Make sure you can connect with the root user with ssh to the new mailserver.

When this has succeeded you can run the following command to import the mailboxes:

php /usr/share/groupoffice-mailserver/import_domain.php

After that you can adjust all mailboxes on the Group-Office database with this SQL command:

UPDATE em_accounts SET host='' WHERE username LIKE '';

Migrate entire linux server

Not really in the scope of Group-Office. But I used this script once to copy an entire Linux server to a new fresh debian installation. Change MIGRATEUSERS to 1 to copy all the users and groups with a UID greater then 500. Change the sources list to suit your needs. Make sure you have trailing slashes for directories otherwise you will sync them one level too deep.

It's also necsarry to create an SSH keypair if you don't have one yet:


Then copy it to the other server:


SOURCES="/etc/ssh/ /etc/ssh/ssh_host_dsa_key /etc/ssh/ssh_host_rsa_key /etc/ssh/ /root/passwd.mig /root/shadow.mig /root/group.mig /quota.user / /home/ /var/www/ /var/lib/mysql/ /vmail/ /usr/share/groupoffice/ /usr/share/www/ /usr/local/kringloopplanner/ /etc/postfix/ /etc/dovecot/ /etc/mailname /etc/apache2/sites-enabled/ /etc/apache2/ssl/ /etc/groupoffice/"

export UGIDLIMIT=500

awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534)' /etc/passwd > /root/passwd.mig

awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534)' /etc/group > /root/group.mig

awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534) {print $1}' /etc/passwd | tee - |egrep -f - /etc/shadow > /root/shadow.mig

#the H option preserves hard links
for source in $SOURCES; do
	rsync -vaH -e "ssh -i /root/.ssh/id_rsa" $source $TARGET:$source

if [ $MIGRATEUSERS -eq 1 ]; then
	ssh -i /root/.ssh/id_rsa $TARGET "cat /root/passwd.mig >> /etc/passwd"
	ssh -i /root/.ssh/id_rsa $TARGET "cat /root/shadow.mig >> /etc/shadow"
	ssh -i /root/.ssh/id_rsa $TARGET "cat /root/group.mig >> /etc/group"

The new server had MySQL 5.1 which uses a different table structure. Running the following command fixed that:

mysql_upgrade -h localhost -u root -p<password>