In a previous blog (https://community.esri.com/t5/arcgis-hub-blog/cloning-a-site-within-hub/ba-p/1539091), I shared steps to clone a site within an organization. Here’s another important use case we often get asked about: how to clone an Enterprise site to Hub and vice-versa. Here are the steps and actions to clone the site item along with associated site pages and groups.
Steps to Clone an Enterprise Site to Hub:
1. Create a Notebook –
2. Connect to your GIS
- The first line in your notebook should contain a pre-populated command to connect to your GIS. Run this cell by clicking the “Run” button on the top ribbon.
3. Install the required library
- In the next cell, enter the following command and then click “Run”:
pip install -e git+https://github.com/esri/hub-py.git#egg=arcgishub
- After the installation is complete, click on “Kernel” in the ribbon, and select “Restart” from the options. You will see this message: “Do you want to restart the current kernel? All variables will be lost. ” Click “Restart” to proceed. This step installs the required library to complete the task.
4. Log in to your ArcGIS Enterprise account
eHub = Hub("url", "username")
- Run the cell, and you will be prompted to enter your password. Once you have entered your password, you are authenticated and ready to proceed.
5. Fetch the site to clone
e_site = eHub.sites.get('ID of the site you want to clone')
e_site.item
- Run the cell to fetch the site that you want to clone.
6. Log in to your Hub account
hub_basic = Hub("url", "username")
- Run the cell, and you will be prompted to enter your password. Once you have entered your password, you are authenticated and ready to proceed.
7. Clone the site
site_cloned = hub_basic.sites.clone(e_site)
site_cloned.item
- Run this command to clone the site. You will be provided with a link to the new site.
For the use case, cloning a Hub site to Enterprise, execute the first four steps above and follow the following steps:
5. Log in to your Hub account
hub_basic = Hub("url", "username")
- Run the cell, and you will be prompted to enter your password. Once you have entered your password, you are authenticated and ready to proceed.
6. Fetch the site to clone
site = hub_basic.sites.get('ID of the site you want to clone')
site.item
7. Log in to your ArcGIS Enterprise account
eHub = Hub("url", "username")
- Run the cell, and you will be prompted to enter your password. Once you have entered your password, you are authenticated and ready to proceed.
8. Clone the site
site_cloned = eHub.sites.clone(site)
site_cloned.item
- Run this command to clone the site. You will be provided with a link to the new site.
Note: If you do not have ArcGIS Notebooks, you can run it in your local Jupyter Notebooks.
Please share your feedback or ideas for further enhancements through the ArcGIS Hub Ideas board in Esri Community.