Skip to main content

One simple script to migrate ArcGIS Enterprise content

Did you ever want to migrate your web applications, web maps, and hosted feature services from your test, development and production server(s)? Or have you ever wanted to migrate content from ArcGIS Online to ArcGIS Enterprise? While you could use ArcGIS Online Assistant to migrate all your content, you would still need to change URLs and item ID’s. This could become quite cumbersome and messy. With ArcGIS API for Python you can deep copy all of that content without having to recreate your work or change the reference URLs.

Script like a Pro!

Please steal this script, you don’t even have to install a Juypter Notebook! Did you know that ArcGIS Pro 2.5 has Juypter Notebooks available?

To learn more, click here.

  1. In a Juypter Notebook or Pro 2.5, insert this code:

from arcgis.gis import GIS

gis_source = GIS('portal1_URL', 'username', 'password', verify_cert=False)

gis_destination = GIS('portal2_URL', 'username_1', 'password_1', verify_cert=False)

print("RUNNING CLONING")

print("---------------")

item = gis_source.content.get('<web_application_item_id>')

cloned_items = gis_destination.content.clone_items(items=[item], copy_data=True)

print("\n FINISHED CLONING")

  1. Change the inputs for ‘portal1_URL’, ‘username’, ‘password’ with the information of your origin Portal.
  2. Change the inputs for ‘portal2_URL’, ‘username’, ‘password’ with the information of your destination Portal.
  3. Change the ‘<web_application_item_id>’ with the origin’s Portal’s Web AppBuilder or a Configurable Web App Template.  
  4. Run the Script
    1. This function will clone all the items to the GIS and swizzle the paths in the web map and web application to point to the new layers. Cloning an item will create a copy of the item and for certain item types, a copy of the item dependencies.
  5. Verify that the content was copied over in Portal 2.
    1. Confirm that the web application (including widgets), web map and hosted feature layer(s) were copied over successfully and that the hosted feature layer URL(s) references in the application were updated.

As reference, here is the note from the documentation for ContentManager.clone_items

Things to Note…

  • This will work for hosted web applications (those built using configurable application templates or Web AppBuilder).
  • Only one hosted web application will run at a time with this sample code.
  • This WILL NOT support cloning of map services, tile layers and scene layers.
  • If the above items are referenced in the web map, the web map will be cloned, but the items will still reference the original service.
  • If you update your source portal’s materials and run the script again, it will not update the destination portal’s items.

Entire Portal to Portal

If you are looking to copy the entire portal to another portal, please refer to this document.

The script in the document contains code samples for cloning groups, users and their contents. Note, this notebook does not copy over the services that power the service-based items. Such items continue to point to the same URL as the ones in source portal did. So long as those URLs remain accessible, the web maps and layer items will continue to be usable.

This video showcases how to do this step-by-step.

If you want to watch the steps being conducted in a video, click here for my YouTube tutorial.

This post was translated to French and can be viewed here

About the Author

Amanda De Medeiros is a Senior Support Enablement Consultant at Esri Canada. She provides support for enterprise customers and internal staff by identifying issues, troubleshooting software, developing workarounds and providing knowledge transfers. Amanda has a BA in Geography and Environmental Studies from McMaster University and a GIS post-graduate degree from Niagara College. Her interest in geography developed from city building and strategy games.

Profile Photo of Amanda De Medeiros