Sitecore makes use of a source and a target database. In order for a content to be visible on the live site, a publish is required. This will transfer the item from the Source Database (Master) to the Target Database (example: Web). For more information about the Publishing Process, you can read my previous post here
More often, it happens that we need to copy one or more items from the target database to the master database. Or even, from the target database on the Staging Environment to the master database of the Production Environment.
In this post, I will show you the two methods that I use to achieve this:
- Using the Transfer Method
- Using Sitecore Package
The transfer method is very simple. The below steps explain how to perform the transfer of items from the target to master database.
Go to the target database and navigate to the item that requires to be transferred.
Right-click on the item, click on the Copying menu then on the Transfer as shown below:
On clicking the transfer option, a window will open with the selected item on the content tree. This window is the source, that is, from where it will take the item.
Clicking on the Next button, the window will now show the destination where you want to transfer it. You can change the database from the dropdown provided above
After selecting the destination database and the path where to transfer the item, click on the Next button. Now, it will shows a summary of what will be transferred and where. You can specify if sub items need to be included.
Click on the Transfer button to start the copying process. Once completed, the window will show the finished result.
Sitecore Package Method
This method is my preferred one. It might take a little longer than the Transfer Method but for me, the Sitecore Package Method is more reliable.
In order to transfer items from the target to master database, you should create a Sitecore Package from the target database first. For example, if I need to transfer items from Web to Master, I will create the package from the Web database.
Once you have the package, please follow the step below in order to be able to install the package on the master database
Open the package, for example, let say your package name is TransferItems.zip. When opening, you will see another zip file in it named package.zip. Open the package.zip
Do not extract the items for the moment.
When opening the package.zip, you will see several folders
Open the installer folder and extract only the project file. After extraction, open the extracted project file in notepad or any text editor. I use Notepad++.
Navigate to the node <Entries>. The statements between the <Entries> node are the different items that will be install. You need to change the path.
Once this is done, drag and drop the updated project file to the same directory in the package. In other words, place it in the installer folder and overwrite the existing one.
Note that a popup will appear after overwriting the file saying that if you want to update the archive. Click on the Yes button.
Open the folder items, you will see the name of the database from which the package has been created. Just rename the folder name to master. Again, a popup will appear to say to update the archive. Click on the Yes button
Note: No extract is required here
Open the folder properties, then the folder items. you will again see the name of the database from which the package has been created. Once again, rename the folder to master. Click on the Yes button to update the archive.
Note: No extract is required here
You may now proceed with your package installation now.
Transfer Method v/s Sitecore Package
Sitecore Package is more reliable and efficient than the Transfer Method. The reasons are as follows:
- Sitecore Package will allow to install items from one environment to another.
- Transfer method tends to timeout if there are large number of items to be copied.
- Transfer method tends to be error prone.