Exchange Online restore using only deleted items option restores duplicate items
When restoring Exchange Online items to the same location more than once, from the same restore point, using the option for deleted items only, you notice some duplicate items have been restored. Specifically, this occurs if you restore, then delete a restored item at the target location, and restore again. A scenario such as this can be common if restores are being tested.
Test folder to restore to contains messages a, b, and c.
Message b is deleted for testing purposes (messages a and c are left)
Deleted messages only option is used to restore messages to the same folder using a restore point.
Messages listed in the target folder are a, b, and c.
Deleted messages only option is used to restore messages to the same folder again from the same restore point.
Messages listed in target folder are now a, b1, b2, and c (where 1 and 2 are different occurrences of the same message item, and show identical in their subject and have the same content.
The iterations in the above example can continue producing duplicates, depending on what messages are deleted. Note that the same restore point is being used to restore with deleted messages only option to the same target folder in Exchange Online.
When we restore any mail to a mailbox in Exchange Online, a new mail message item is created as intended, but with a new message ID that is internal to Exchange Online. Exchange online will not allow the creation of a mail message item in a mailbox that has a message ID that has already existed in that mailbox. This is as designed by Microsoft Exchange Online, and implemented through its available APIs as used for restore purposes.
Therefore, when a restore is triggered for the first time, the items get restored without creating duplicates. As a second restore is triggered, the deleted mail items which had been already restored have new message IDs, but the backup restore point used contains the same messages but with different message IDs.
The restore process matches message IDs to check if they are present in the target folder. In the case of a second restore as in the example described, since the old message ID ( from the backed up mail item ) does not match the already present new message ID, then duplicate email items are created in the same folder.
The above is expected behaviour for the restore process as described.
To avoid this issue, and in case it is necessary to demonstrate the restore process a second time to the same target, using the same deleted items only option, and using the same restore point, a new backup of the target folder should be created, and the resulting restore point used to restore items from in the same manner. This will avoid creating duplicate mail items upon a second or subsequent restore(s).