- Home
- Workspace
- Installation
- Enterprise
- Docker
- Migrating MS Exchange data to ONLYOFFICE
Migrating MS Exchange data to ONLYOFFICE
Introduction
This article describes how to transfer data from MS Exchange to ONLYOFFICE. Currently, the following data types are supported for transfer:
- users,
- mailboxes,
- mail messages.
In the next releases, we are going to add support for the following data:
- calendars,
- contacts,
- tasks.
Export data from MS Exchange
Running the necessary service
First, make sure that the Microsoft Exchange Mailbox Replication (MSExchangeMailboxReplication) service is running. Run the following command in the cmd console:
Get-Service -name MSExchangeMailboxReplication
If the service you need is running, the command result will look like this:
Status Name DisplayName
------ ---- -----------
Running MSExchangeMailb... Microsoft Exchange Mailbox Replication
Alternatively, go to the Windows Control Panel > Administrative Tools > Services, find the Microsoft Exchange Mailbox Replication service, and run it.
Assigning the rights
Assign the administrative rights to the user who is going to export the mailboxes from MS Exchange:
New-ManagementRoleAssignment -Role "Mailbox Import Export" -User <user name>
Where <user name> is the name of the user who is going to export the data. If you are going to do that yourself, assign this role to your account.
New-ManagementRoleAssignment -Role "Mailbox Import Export" -User JohnAfter that, restart the Exchange Web Services (EWS) console with the administrator rights. To do that, right-click the EWS icon in the Start menu and select the Run as administrator option.
Running the script
Now download the script that will do everything you need for the correct export of the data from MS Exchange. The script is available via this link. Once downloaded, run it in the EWS console:
.\ExportExchangeData.ps1 -dir "C:\Temp"
Where .\ExportExchangeData.ps1 is the path to the script, and -dir "C:\Temp" is the path to the folder that will be used to export the files.
-dir parameter will be shared with everyone. This is necessary for the correct work of the New-MailboxExportRequest command. After the script finishes its work, the sharing will be removed from the folder.The folder with the exported files then needs to be transferred to the computer with ONLYOFFICE installed.
PST files have the correct data in them, you can use the free pst-viewer tool to do that.- First, the script creates the folder set with the
-dirparameter above. If the parameter is missing, the defaultC:\Tempfolder will be used. - Once created, the folder is shared with everyone, so that the
New-MailboxExportRequestcommand can work correctly. - Then the script checks if the file for the user list has been previously created and deletes it if found. The user list is exported using the following command:
Get-Mailbox | Select DisplayName, PrimarySmtpAddress, Alias | Export-Csv $usersListPath - After that, the folder for the mailboxes is created, and the old one is removed if present. Then the user mailbox export starts. It will take some time depending on the number of users, their mailboxes, and the data present in their mail messages. The mailboxes and messages will be saved in the PST format to the
\PST\folder of the directory previously set with the-dirparameter. To other computers over the network, this folder will look like\\ServerName\Temp\PST\. - Finally, the share is removed from the folder, and the script finishes its work.
While the script is running, some errors might occur. Below are the most frequent ones and the ways to solve them.
-
Error #1
The name must be unique per mailbox. There isn't a default name available for a new request owned by mailbox 'mailbox.local/folder/user'. Please clean up existing requests by using the Remove cmdlet or specify a unique name. + CategoryInfo : InvalidArgument: (mailbox.local/folder/user:MailboxOrMailUserIdParameter)[New-MailboxExportRequest], NoAvailableDefaultNamePermanentException + FullyQualifiedErrorId : [Server=ServerName,RequestId=4a67e451-556c-4ba0-9ab9-9d2ce8a120ff,TimeStamp=11/7/2017 9:46:58 AM] [FailureCategory=Cmdlet-NoAvailableDefaultNamePermanentException] 7B0B3FF9, Microsoft.Exchange.Management.Migration.MailboxReplication.MailboxExportRequest.NewMailboxExportRequest + PSComputerName : servername.mailbox.localSolution
Run the following command:
Get-MailboxExportRequest | Remove-MailboxExportRequest -
Error #2
New-MailboxExportRequest : The term 'New-MailboxExportRequest' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:39 + ... oreach ($Mailbox in (Get-Mailbox)) { New-MailboxExportRequest -Mailbo ... + ~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (New-MailboxExportRequest:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundExceptionSolution
Restart the EWS console and make sure you run it with the administrator rights.
-
Error #3
\\ServerName\Temp\PST\user.pst The server or share name specified in the path may be invalid, or the file could be locked. + CategoryInfo : NotSpecified: (:) [New-MailboxExportRequest], RemotePermanentException + FullyQualifiedErrorId : [Server=ServerName,RequestId=40efdbf2-53bf-47e8-92b8-f8fa8a8f15db,TimeStamp=11/7/2017 9:55:48 AM] [FailureCategory=Cmdlet-RemotePermanentException] 94719DAF, Microsoft.Exchange.Management.Migration.MailboxReplication.MailboxExportRequest.NewMailboxExportRequest + PSComputerName : servername.mailbox.localSolution
The
\\ServerName\Tempfolder, the one used for the mailbox export and set with the script-dirparameter, must be shared for reading and writing access. If you shared it previously, check whether it has the writing access only and change the access accordingly.
Import the MS Exchange data to ONLYOFFICE
Installing ONLYOFFICE Workspace Enterprise Edition and configuring Mail Server
Install the Docker version of ONLYOFFICE Workspace Enterprise Edition. This can be done by installing ONLYOFFICE Workspace Enterprise Edition using the script and selecting the Docker installation option. After that, set up the mail server as described in this article.
users.csv file, which was received in the step above, replacing all the entries for the old MS Exchange domain with the new one. This is done with the following command:
sed -i 's/exchange-domain.com/new-domain.com/g' users.csv
Where exchange-domain.com is the old domain name used with MS Exchange, and new-domain.com is the new one you are now going to use.
Downloading the script and installing or updating dependencies
Now you need to download and unpack the script that will perform the data import. This can be done using the following command:
wget -O "ImportExchangeData.tar" "https://help.onlyoffice.com/products/files/httphandlers/filehandler.ashx?action=view&fileid=5549294&version=0&doc=TWVPQks1aUo2MEprc0tkbUF6K2Y4Um1OSi9tTkd6V0lyTHFocG0xZHE0QT0_IjU1NDkyOTQi0" && tar -xvf ImportExchangeData.tar && cd ./Import
The command will download and unpack the file, creating the following folder structure:
Import
|-lib
|---create_users.py
|---mbox2imap.py
|---mapping.json
|---pst2mbox.sh
|---get-mailboxes.sh
|---install-passfinder.sh
|---ASC.Mail.PasswordFinder.tar
|-ImportExchangeData.py
|-requirements.txt
You will need Python v2.7 installed. It is often installed by default with various Linux distributions, but if it is missing, you will need to install it yourself. This is how it is done for Debian-based distributions:
# apt install python
# python -V
Python 2.7.12
Install the pip package manager, which is also necessary for the correct script work:
# apt install python-pip
# pip -V
pip 9.0.1 from /usr/local/lib/python2.7/dist-packages (python 2.7)
And install the other required packages:
pip install -r requirements.txt
Running the script
Now you can run the script specifying the necessary parameters:
./ImportExchangeData.py -d "<portal domain>" -u "<portal administrator email>" -pw "<portal administrator password>" -f <path to the folder with the exported data>
-s "https" parameter when running the code.Replace the parameters in brackets with your own portal data and run the script:
./ImportExchangeData.py -d myportal.com -u "my.email.address@gmail.com" -pw "123456" -f /root/Temp/Wait for the script to finish working. It might take some time depending on the number of users and the amount of their data.
Script work results
When the script finishes its work, the results will be the following:
- the new portal users with the email addresses from the
users.csvfile will be created; - the mailboxes on the ONLYOFFICE Mail Server will be created; they will contain the mail messages from MS Exchange and will be connected in the ONLYOFFICE Mail module for the users listed in the
users.csvfile; - the
results-ok.txtfile will be saved to theImportfolder; it will contain the list of all the user accounts from theusers.csvfile that were successfully created, and their passwords; - the
result-err.txtfile will be saved to theImportfolder; it will contain the list of all the user accounts from theusers.csvfile that had problems when being imported and created; - the
mailboxes.jsonfile in theJSONformat will be saved to theImportfolder; it will contain the list of settings necessary to connect to the newly created mailboxes from third-party mail clients.
ImportExchangeData.py folder and run the following command:
bash ./lib/get-mailboxes.sh -j
The mailboxes.json file will be overwritten with the new mailbox data.
- When run, the script sets the main working files and folders: both the files and folders necessary for the output files and the folder with the input data, which has been exported from MS Exchange.
- At the next step, the script creates the users and then their mailboxes.
- Then the script converts the exported files into the
mboxformat. - When done, the script installs the
ASC.Mail.PasswordFinderprogram that will assist in creating themailboxes.jsonfile containing the list of settings necessary to connect to the newly created mailboxes from third-party mail clients. - After that, the
mailboxes.jsonfile itself is created. - Finally, the
mboxformat files are imported to the mailboxes via IMAP.