In continuation to my previous posts I will be sharing some steps in which we can package up the Archived items and move them from one Sitecore instance to another.
This can be a requirement for many migration projects.
Note: We can only create a package for items which are in content tree(i.e non Archived/deleted).
Following are the steps we can follow to move archived items:
1. Get list of all archived items from source instance master DB. (programmatically)
2. Restore the list of archived items from step 1 to the source instance. (programmatically)
3. Create Sitecore items package of the restored items. (programmatically)
4. Archive the restored items again on source instance DB. (programmatically)
5. Grab the sitecore package created in step 3 above and install it on the destination instance.
6. Read items from the package and archive them.
The above 5 steps are discussed previously and can be seen by clicking on them.
Below is a way to perform Step 6: Reading the items from Sitecore package and the archiving them that were moved as part of the package.
1. Extract the package .zip file and under the package folder -> installer folder, we can find a file called "project".
If we open the file in notepad we can see all the items that were part of the package are in an xml format.
2. Copy this file and paste it in data folder in C drive (C:/Data)
3. Rename it to project.xml with file extensions as turned ON.
4. Run the following code method to read only the item id from the xml and fetching the item from that id, and then archiving it:
Now, if you go and check your Sitecore Archive application, you will find the items are present in it.