How to export import emails for a specific date
How to export/import emails for a specific date?
Problem
How to export/import emails between two dates through CLI?
Steps
1)Run following command to export emails.
$ zmmailbox -z -m alice@example.com gru "//?fmt=tgz&query=after:"7/20/2022"&before:"7/26/2022"" >> /tmp/alice.tgz
It will create a .tgz file into /tmp directory.
2) Create folder, where you want to import emails:
$ zmmailbox -z -m bob@example.com cf /Exported_data
3) Copy the .tgz file into the mailbox server where you want to import. Make sure file permission and ownership should be:
-rw-r----- 1 zimbra zimbra 12K Jul 26 05:13 alice.tgz
4) Try to import emails. Run on new server or any other server where you want to import emails:
$ zmmailbox -z -m bob@example.com postRestURL "/Exported_data?fmt=tgz&resolve=replace" /tmp/alice.tgz
Note: Zimbra doesn't support export-import of large mailbox in tgz because of broken .tgz file and other IO error.