<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic A script to copy hosted feature layers from one Portal to another Portal on the same network? in ArcGIS Enterprise Questions</title>
    <link>https://community.esri.com/t5/arcgis-enterprise-questions/a-script-to-copy-hosted-feature-layers-from-one/m-p/1319533#M36873</link>
    <description>&lt;P&gt;We've tried using AGOL Assistant and ArcGIS Assistant to copy our hosted feature services across from one Portal to another Portal (part of a Portal migration due to a team breaking away from another team).&amp;nbsp;&lt;/P&gt;&lt;P&gt;ArcGIS Assistant only supports copying referenced items (rest service still pointing back to original portal)&lt;/P&gt;&lt;P&gt;AGOL Assistant copying in "Full" mode is unstable, and either fails for the larger services or doesn't bring the symbology across.&lt;/P&gt;&lt;P&gt;We would like a script that will look at the old feature service, download it as FGDB to a local drive and then publish back up to the new portal, with matching naming, metadata, symbology, and - if possible - the same group sharing (pointing to new identical groups on new portal).&lt;/P&gt;&lt;P&gt;Has anyone done this before?&lt;/P&gt;&lt;P&gt;We would probably then use AGOL Assistant to repoint the layers in the WebMaps to the new URLs, but would be keen to hear other options on this too.&lt;/P&gt;</description>
    <pubDate>Thu, 17 Aug 2023 11:36:16 GMT</pubDate>
    <dc:creator>David_Brooks</dc:creator>
    <dc:date>2023-08-17T11:36:16Z</dc:date>
    <item>
      <title>A script to copy hosted feature layers from one Portal to another Portal on the same network?</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/a-script-to-copy-hosted-feature-layers-from-one/m-p/1319533#M36873</link>
      <description>&lt;P&gt;We've tried using AGOL Assistant and ArcGIS Assistant to copy our hosted feature services across from one Portal to another Portal (part of a Portal migration due to a team breaking away from another team).&amp;nbsp;&lt;/P&gt;&lt;P&gt;ArcGIS Assistant only supports copying referenced items (rest service still pointing back to original portal)&lt;/P&gt;&lt;P&gt;AGOL Assistant copying in "Full" mode is unstable, and either fails for the larger services or doesn't bring the symbology across.&lt;/P&gt;&lt;P&gt;We would like a script that will look at the old feature service, download it as FGDB to a local drive and then publish back up to the new portal, with matching naming, metadata, symbology, and - if possible - the same group sharing (pointing to new identical groups on new portal).&lt;/P&gt;&lt;P&gt;Has anyone done this before?&lt;/P&gt;&lt;P&gt;We would probably then use AGOL Assistant to repoint the layers in the WebMaps to the new URLs, but would be keen to hear other options on this too.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Aug 2023 11:36:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/a-script-to-copy-hosted-feature-layers-from-one/m-p/1319533#M36873</guid>
      <dc:creator>David_Brooks</dc:creator>
      <dc:date>2023-08-17T11:36:16Z</dc:date>
    </item>
    <item>
      <title>Re: A script to copy hosted feature layers from one Portal to another Portal on the same network?</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/a-script-to-copy-hosted-feature-layers-from-one/m-p/1319900#M36875</link>
      <description>&lt;P&gt;You can try use the clone_items to move between environments.&lt;/P&gt;&lt;P&gt;Have a look at this for a step-by-step:&lt;A href="https://developers.arcgis.com/python/guide/cloning-content/" target="_blank" rel="noopener"&gt;&amp;nbsp;https://developers.arcgis.com/python/guide/cloning-content/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Aug 2023 22:19:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/a-script-to-copy-hosted-feature-layers-from-one/m-p/1319900#M36875</guid>
      <dc:creator>julian_svcs</dc:creator>
      <dc:date>2023-08-17T22:19:30Z</dc:date>
    </item>
    <item>
      <title>Re: A script to copy hosted feature layers from one Portal to another Portal on the same network?</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/a-script-to-copy-hosted-feature-layers-from-one/m-p/1321941#M36943</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/415930"&gt;@David_Brooks&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;You can try this Python script that involves exporting a hosted feature layer from AGOL to a local File Geodatabase (GDB) and then uploading that GDB back to AGOL. Let's break down each block of the code:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;&lt;STRONG&gt;Block 1: Connecting to ArcGIS Online and User Input&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;The outputFolder variable stores the local path where the GDB will be extracted.&lt;/LI&gt;&lt;LI&gt;The username variable captures user input for their ArcGIS Online username.&lt;/LI&gt;&lt;LI&gt;The GIS class is used to create a connection to ArcGIS Online using the provided URL and username.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;&lt;STRONG&gt;Block 2: Exporting Hosted Feature Layer from AGOL&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;The item_id variable holds the ID of the hosted feature layer to be downloaded from AGOL.&lt;/LI&gt;&lt;LI&gt;AGOLitem is a reference to the hosted feature layer item on AGOL.&lt;/LI&gt;&lt;LI&gt;The export method is used to export the hosted feature layer to a GDB named Temp_FGB. The export process is waited for (using wait=True), and then there's a delay of 10 seconds before proceeding.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;&lt;STRONG&gt;Block 3: Reconnecting to ArcGIS Online or the new portal&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;This block of code re-establishes a connection to ArcGIS Online with a different URL.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;&lt;STRONG&gt;Block 4: Uploading GDB to ArcGIS Online&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;data_path stores the path to the ZIP file containing the GDB exported in the earlier block.&lt;/LI&gt;&lt;LI&gt;zip_properties define the type of item being added (a File Geodatabase in this case).&lt;/LI&gt;&lt;LI&gt;add_fgdb represents the newly uploaded GDB item on ArcGIS Online&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;&lt;STRONG&gt;Block 5: Sharing the GDB Item&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;This block shares the uploaded GDB item with a specific group identified by its ID ("32cc4d232e45464d8c536a076c2f0d70"). Replace this ID with the ID of the group you want to share the information.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;#Block 1: Connecting to ArcGIS Online and User Input
outputFolder=r"C\Test_fGDB" #replace this with the path where the GDB will be extracted to
username = input("Input your username: ")
gis = GIS("https://arcgis.com", username) #replace these with the credentials of your source portal

#Block 2: Exporting Hosted Feature Layer from AGOL
item_id='f8f66537f7504bc1b2bd4585e83c13ec' #replace with the service_ID of the hosted feature layer to download
GDBname = "Temp_FGB" #name of the temporary GDB to be saved in ArcGIS Online

AGOLitem = gis.content.get(item_id)

print ("Exporting Hosted Feature Layer...")
AGOLitem.export(GDBname,'File Geodatabase', parameters=None, wait='True')
time.sleep(10)#add 10 seconds delay to allow export to complete

search_fgb = gis.content.search(query = "title:{}*".format(GDBname )) #find the newly created file geodatabase in ArcGIS online
fgb_item_id = search_fgb[0].id
fgb = gis.content.get(fgb_item_id)
fgb.download(save_path=outputFolder) #downloads the fgdb on the path you selected

#Block 3: Reconnecting to ArcGIS Online
from arcgis.gis import GIS
import getpass
username = input("Input your username: ")
gis = GIS("https://esp-esri-co.maps.arcgis.com", username) #replace these with the credentials of your target portal

#Block 4: Uploading GDB to ArcGIS Online
import os
from arcgis.gis import GIS
data_path = (r"C:\Users\vurrego\Documents\Test_fGDB\Temp_FGB.zip") #Where the fgdb is saved
zip_properties = {'type':'File Geodatabase'} #type of the document you want to upload
add_fgdb = gis.content.add(item_properties = zip_properties, data = data_path) #Adds the fgdb on your portal content
print("The fGDB is uploaded")

#Block 5: Sharing the GDB Item
add_fgdb.share(groups="32cc4d232e45464d8c536a076c2f0d70") #replace with the id of the group you want to share&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope this will be useful for you!&amp;nbsp;&lt;/P&gt;&lt;P&gt;Have a great day.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Aug 2023 21:42:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/a-script-to-copy-hosted-feature-layers-from-one/m-p/1321941#M36943</guid>
      <dc:creator>VeronicaUrrego</dc:creator>
      <dc:date>2023-08-23T21:42:39Z</dc:date>
    </item>
  </channel>
</rss>

