ZCS-to-ZCS Migrations

Someone in the forums recently asked about ways to migrate individual accounts from one ZCS instance to another, so thought I’d share the enlightenment with all. Whether you are going from an on-premise install to a hosting provider, want to create handy archives of old employee accounts, or just need to duplicate mailbox contents of a user; the syntax in this article proves remarkably useful, and applies to all editions.
ZCS-to-ZCS
There are a multitude of comparable RFE’s on addressing this need via different approaches. (Bugzilla entries 19630, 29573, 28443 & 30163 to name a few.) Some want graphical tools to browse data and selectively migrate certain things, while others would be happy with a cross LDAP zmmailboxmove.

Depending on your situation, several backup tools can take care of a large portion of your daily needs; and there are ways to do Zimbra-to-Zimbra migrations using the Network Edition’s backup and restore capabilities – however they require admin abilities on both systems. Meanwhile, most of the frequently used open source backup solutions are simply an “all accounts at-once” approach. So what to do when you need to move from your personal setup to a hosting provider? Or if you’re a hosting provider, move a tiny handful of accounts to a separate infrastructure? Before diving into the wiki on user migration for info on Imapsync, REST exports, CURL imports, etc; there’s a handy way to avoid the “one item type at-a-time” transfer methods.

In ZCS 5.0.9+ you can export an entire mailbox with:
/opt/zimbra/bin/zmmailbox -z -m user@domain.com getRestURL “//?fmt=tgz” > /tmp/account.tgz

Next transfer via rsync, scp, sftp, etc. You’ll also need to create the account on the 2nd server if the desired account doesn’t exist at your destination server yet.

Then import with:
/opt/zimbra/bin/zmmailbox -z -m user@domain.com postRestURL “//?fmt=tgz&resolve=reset” /tmp/account.tgz

The resolve= paramater has several options:

  • “skip” ignores duplicates of old items, it’s also the default conflict-resolution.
  • “modify” changes old items.
  • “reset” will delete the old subfolder (or entire mailbox if /).
  • “replace” will delete and re-enter them.

‘Reset’ will be a bit faster on an empty destination mailbox because it skips most dupe checks.

Note: There were some duplication fixes and additional issues (mainly sync related) corrected with the tar formatter in 5.0.10.

Not a Zimbra Admin? Users can get the same zip/tar formatter on REST URL’s by visiting:
http:// server.domain.com/home/user?fmt=zip&query=is:anywhere

The zip format has been around for a long time, but doesn’t contain account & item metadata like the tar formatter automatically does:
http:// server.domain.com/home/user/?fmt=tgz

ZD Export Backup AlphaInfact, this same technique is currently used in Zimbra Desktop’s alpha backup solution.

If this approach doesn’t scale performance wise for your situation, or you simply don’t want to have everyone hit a REST URL for 30GB mailboxes all at the same time, here’s a collection of helpful scripts and other ways to systematically migrate:

Mysqldump & rsync with an interesting blob management technique: Zimbra2Zimbra

Imapsync for mail + postRestURL for contacts, calendar & filters: ZimbraMigrate (Expand the concept for tasks, documents, and briefcase items.)

Another method that could be extrapolated upon for migrations: Per User Mailbox Backup (OE Version – Zimbra :: Wiki)

Most of these solutions aren’t going to respect share permissions, but when pulling an account out of an environment that’s to be expected.

Zimlet spin-offs:
– Mail backup options for end users (.eml)
– Zimlet to save email in a txt file (.txt or html)

The above Zimlets are aimed at making quick self-copies & not for restores, but there are many methods for putting messages back into Zimbra, including tools like zmmailbox addMessge, zmlmtpinject, CURL, etc; for more info checkout these threads: Recover data from store folders & Moving Folders between users

If moving your entire server, I’m a huge fan of the install.sh -s trick when using NE backups to do so isn’t an option.


Have another method you’d like to share? Document it in the wiki & note it below, or you can discuss over in the Community Forums.

12 Responses to ZCS-to-ZCS Migrations

  1. Mike Morse January 16, 2010 at 7:23 PM #

    5.0.16+ has a new zmztozmig tool bundled http://bugzilla.zimbra.com/show_bug.cgi?id=30163

  2. yendereb May 18, 2010 at 4:09 PM #

    I’m have Debian Lenny 5.0 and zimbra Release 6.0.5_GA_2213.DEBIAN5 DEBIAN5 FOSS edition.

    try to migrate account with this method

    On the old server backup is OK.
    On new server I create empty account and try to import data but I have this error:

    ERROR: service.FAILURE (system failure: POST failed, status=404 Not Found)

    Please, help me!

  3. Wesley December 7, 2010 at 8:12 PM #

    how to export the list of zimbra in xmpp

  4. Rafael February 2, 2011 at 8:55 PM #

    Hello,

    thanks for this wonderful article.

    I`m running a Zimbra using ldap for authetication, but, when I tried to run the command for backups

    /opt/zimbra/bin/zmmailbox -z -m myuser@mydomain.com getRestURL “//?fmt=tgz” > /tmp/account.tgz

    Exception in thread “main” java.lang.IllegalArgumentException: Invalid uri ‘http://mail.mydomain.com/home/myuser@mydomain.com/“?fmt=tgz”’: escaped absolute path not valid
    at org.apache.commons.httpclient.HttpMethodBase.(HttpMethodBase.java:219)
    at org.apache.commons.httpclient.methods.GetMethod.(GetMethod.java:88)
    at com.zimbra.cs.zclient.ZMailbox.getRESTResource(ZMailbox.java:2507)
    at com.zimbra.cs.zclient.ZMailbox.getRESTResource(ZMailbox.java:2472)
    at com.zimbra.cs.zclient.ZMailboxUtil.doGetRestURL(ZMailboxUtil.java:2760)
    at com.zimbra.cs.zclient.ZMailboxUtil.execute(ZMailboxUtil.java:1057)
    at com.zimbra.cs.zclient.ZMailboxUtil.main(ZMailboxUtil.java:2654)

    Could you help me to find the right way to backup user who use LDAP?

    Thanks in advance!

    Rafael

  5. Nizam Idris April 4, 2012 at 10:53 AM #

    zmztozmig migration does not migrate shared calendar and shared files. Is there a way to migrate these shared resources via commandline tools? zmmailboxmove maybe? If they share the same LDAP master or cross LDAP?

  6. webinar wealth tsunami review June 25, 2012 at 8:15 AM #

    Hello to every one, since I am actually eager of reading this
    website’s post to be updated on a regular basis. It contains nice information.

Trackbacks/Pingbacks

  1. Live Backup For Zimbra FOSS Edition « #!/Dudi/Gurnadi - February 11, 2010

    […] made a bash script to do a zimbra live backup for FOSS Edition. This script has been made based on this reference and this […]

  2. 5.0.19 <-> 5.0.19 Migration - Zimbra - Forums - February 11, 2010

    […] started testing ZCS-to-ZCS Migrations this morning. I'm also seeing posts about a migration tool, "zmztozmig". Anyone know […]

  3. Mail address username issue for internal mails on Zimbra server - Zimbra :: Forums - February 26, 2012

    […] […]

  4. Moving Email Data from Old Account to New account (both on zimbra) - Zimbra :: Forums - March 22, 2012

    […] […]

  5. Question :zimbra and backup on four virtual server - Zimbra :: Forums - May 21, 2012

    […] […]

  6. Any API to create event on user's calendar without authentication? - August 1, 2012

    […] work to import with REST in another account. Here is some informations on it on zimbra blog : zcs-to-zcs migrations Reply With Quote « Previous Thread | Next Thread […]

Copyright © 2022 Zimbra, Inc. All rights reserved.

All information contained in this blog is intended for informational purposes only. Synacor, Inc. is not responsible or liable in any manner for the use or misuse of any technical content provided herein. No specific or implied warranty is provided in association with the information or application of the information provided herein, including, but not limited to, use, misuse or distribution of such information by any user. The user assumes any and all risk pertaining to the use or distribution in any form of any subject matter contained in this blog.

Legal Information | Privacy Policy | Do Not Sell My Personal Information | CCPA Disclosures