View Single Post
  #5 (permalink)  
Old 05-05-2007, 02:40 AM
area area is offline
Active Member
 
Posts: 47
Default

I looked at this issue in the last few days and explored the option of exporting a user's mail folders and importing them under a folder of another user (such as the admin user). My aim was to do the export/import completely on the server and with a view to automating the 'move' operation.

My summary of the export/import options is below. There is no easy or perfect way of doing this and after all this testing, I think I will use Thunderbird to transfer the folders.

Exporting can be done two ways:

a) using the zmmboxsearch command on the user's account with a query of 'before today''; this dumps
all emails from all folders into the one directory with file names like:

00502_bf1458f7-e1aa-4dd4-addd-04f65331093d_466
00500_bf1458f7-e1aa-4dd4-addd-04f65331093d_467
00501_bf1458f7-e1aa-4dd4-addd-04f65331093d_465
00498_bf1458f7-e1aa-4dd4-addd-04f65331093d_468
00499_bf1458f7-e1aa-4dd4-addd-04f65331093d_469
00497_bf1458f7-e1aa-4dd4-addd-04f65331093d_471
00494_bf1458f7-e1aa-4dd4-addd-04f65331093d_473
00495_bf1458f7-e1aa-4dd4-addd-04f65331093d_472
00496_bf1458f7-e1aa-4dd4-addd-04f65331093d_470

It doesn't preserve folder structures. An example command to dump all the emails from all folders
for a user to /var/tmp/ would be:

su - zimbra -c "zmmboxsearch --query 'before:today' --mbox fred@yourcompany.com --dir /var/tmp/fred --limit 9999"

b) using a REST URL from either a browser or the command line using the wget command: eg:

wget --no-check-certificate --http-user=fred@yourcompany.com --http-passwd=password \
"https://zimbra.yourcompany.com/zimbra/home/fred@yourcompany.com/Inbox.zip"

However, this can only be done on a per-folder basis - there is a parameter in the specifications
to get all folders ('recursive=1') but the server responds with 'not implemented yet'.

Question to Zimbra folks - any update on when this option will be available?

You could write a script to list all the email folders for a user and then run wget for each folder
so that you would end up a .zip file for each folder.


Importing to a new folder on another account can be done from both types of export:

a) directly from the directory of email messages saved by zmmboxsearch: eg:

su - zimbra -c "zmmailbox -z -m admin@yourcompany.com"
createFolder /Fred
addmessage /Fred /var/tmp/fred

b) unzipping each .zip file to a folder (the folder structure is recorded in the .zip file) and then
importing each folder one at a time:

cd /var/tmp
unzip /tmp/Inbox.zip
su - zimbra -c "zmmailbox -z -m admin@yourcompany.com"
createFolder /Fred
addmessage /Fred /var/tmp/Inbox

However, the received date of all the messages is set to today; ie: the date the message was received. I did once write a script to update the received date in the MySQL database to the date from the Date: header of the email.
Reply With Quote