<?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 Re: Output name oddity using FeatureClassToGeodatabase to copy hosted feature layers in AGO in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/output-name-oddity-using-featureclasstogeodatabase/m-p/1326558#M68543</link>
    <description>&lt;P&gt;If I try to run it in Pro 2.x I get that error as it doesn't appear as if it was added until Pro 3.&lt;/P&gt;&lt;P&gt;R_&lt;/P&gt;</description>
    <pubDate>Thu, 07 Sep 2023 20:14:10 GMT</pubDate>
    <dc:creator>RhettZufelt</dc:creator>
    <dc:date>2023-09-07T20:14:10Z</dc:date>
    <item>
      <title>Output name oddity using FeatureClassToGeodatabase to copy hosted feature layers in AGO</title>
      <link>https://community.esri.com/t5/python-questions/output-name-oddity-using-featureclasstogeodatabase/m-p/1324823#M68513</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I'm working on a python script to back up hosted feature layers in AGO to a local file geodatabase.&lt;/P&gt;&lt;P&gt;I'm aware of this one on ESRI's knowledge-base,&amp;nbsp;&lt;A href="https://support.esri.com/en-us/knowledge-base/how-to-back-up-hosted-content-by-looping-through-and-do-000022524," target="_blank"&gt;https://support.esri.com/en-us/knowledge-base/how-to-back-up-hosted-content-by-looping-through-and-do-000022524,&lt;/A&gt;&amp;nbsp;but it's a little more broad than I'm really looking for. And I'm trying to develop something that's friendly for people who aren't as familiar with python (or scripting in general). Idea being that someone can just add a layer to the map and it'll get included in the back up and you don't have to worry about getting tags, categories, or ownership stuff set up. Best practice aside, that's that reality.&lt;/P&gt;&lt;P&gt;Here's the script I'm running and it works but I sometimes get an odd output for the feature class names like "GPLYR - [GlobalID looking string]" (see snip below the code).&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;# Set the Pro project (.aprx) that contains the layers you want to share/publish.&lt;BR /&gt;prj = arcpy.mp.ArcGISProject('Current') # Set, uses this aprx&lt;BR /&gt;mp = prj.listMaps("Storm Damage Assessment")[0]&amp;nbsp;&lt;BR /&gt;lyrlist = mp.listLayers()&lt;/P&gt;&lt;P&gt;# Set output locations and name&lt;BR /&gt;outdir = r"C:\GIS Data" # SET, where should the file geodatabase and feature classes go?&lt;BR /&gt;fgdbname = r"Storm Damage Assessment" # SET, name the new file geodatabase to be created.&lt;/P&gt;&lt;P&gt;# Date/time&lt;BR /&gt;date = time.strftime("%Y%m%d")&lt;/P&gt;&lt;P&gt;AGOBackupfgdb = arcpy.management.CreateFileGDB(outdir, fgdbname + "_" + date)&lt;BR /&gt;#AGOBackuppath = os.path.join(outdir, fgdbname + "_" + date + ".gdb")&lt;BR /&gt;#print(AGOBackuppath)&lt;/P&gt;&lt;P&gt;try:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; for lyr in lyrlist:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print ("Exporting " + lyr.name)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; arcpy.conversion.FeatureClassToGeodatabase(lyr,AGOBackupfgdb)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;#arcpy.conversion.ExportFeatures(lyrL, AGOBackuppath + "\\" + lyr.name)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;print("\t Success")&lt;BR /&gt;except:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;print("Failed to export to file geodatabase.")&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="twangtx_0-1693585684304.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/79669i3BD77C0226E325E9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="twangtx_0-1693585684304.png" alt="twangtx_0-1693585684304.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I've also written another version of the script that loops through all the maps in the Pro Project to copy the hosted feature layers to file geodatabase (one per map). Usually one of the back up sets of hosted feature layers has the correct names but the others have that GPLYR name for the feature class.&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;try:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;for m in mp:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print("Backing up layers from " + m.name)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; lyrlist = m.listLayers()&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; AGOBackupfgdb = arcpy.management.CreateFileGDB(outdir, m.name + "_" + date)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; lyrlist = m.listLayers()&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;for lyr in lyrlist:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print ("\t" + lyr.name)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; arcpy.conversion.FeatureClassToGeodatabase(lyr,AGOBackupfgdb)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print("\t Done \n")&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print("Successfully backed up layers")&lt;BR /&gt;except:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;print("Failed")&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Maybe FeatureClasstoGeodatabase isn't the best method? I'm trying to use ExportFeatures, but for whatever reason I cannot get it to work. It looks like there are some parameters from FeatureClasstoFeatureClass that didn't get carried over to ExportFeatures when it get deprecated.&lt;/P&gt;&lt;P&gt;Thank you for any help or input on improving the script methodology or why some feature classes are getting named GPLYR and how to solve it.&lt;/P&gt;&lt;P&gt;Thomas&lt;/P&gt;</description>
      <pubDate>Fri, 01 Sep 2023 16:44:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/output-name-oddity-using-featureclasstogeodatabase/m-p/1324823#M68513</guid>
      <dc:creator>twangtx</dc:creator>
      <dc:date>2023-09-01T16:44:22Z</dc:date>
    </item>
    <item>
      <title>Re: Output name oddity using FeatureClassToGeodatabase to copy hosted feature layers in AGO</title>
      <link>https://community.esri.com/t5/python-questions/output-name-oddity-using-featureclasstogeodatabase/m-p/1325480#M68528</link>
      <description>&lt;P&gt;Not sure where that is coming from, but I use a modified version of the link you provided.&lt;/P&gt;&lt;P&gt;Once connected, you can query by Hosted Feature Service name rather than worrying about tags, ownership, etc.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;query_string =  f"type:Feature Service, title:SSA_Map_Data"&lt;/LI-CODE&gt;&lt;P&gt;But will backup the entire HFS, not just individual layers.&lt;/P&gt;&lt;P&gt;In case it helps,&lt;/P&gt;&lt;P&gt;R_&lt;/P&gt;</description>
      <pubDate>Tue, 05 Sep 2023 16:42:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/output-name-oddity-using-featureclasstogeodatabase/m-p/1325480#M68528</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2023-09-05T16:42:45Z</dc:date>
    </item>
    <item>
      <title>Re: Output name oddity using FeatureClassToGeodatabase to copy hosted feature layers in AGO</title>
      <link>https://community.esri.com/t5/python-questions/output-name-oddity-using-featureclasstogeodatabase/m-p/1326552#M68542</link>
      <description>&lt;P&gt;Does anyone else get the error below when&amp;nbsp;&lt;SPAN&gt;&lt;SPAN class=""&gt;arcpy.conversion.ExportFeatures(x,y,"alias"...) is ran?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;AttributeError: 'module' object has no attribute 'ExportFeatures'&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Sep 2023 19:54:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/output-name-oddity-using-featureclasstogeodatabase/m-p/1326552#M68542</guid>
      <dc:creator>rfan27</dc:creator>
      <dc:date>2023-09-07T19:54:38Z</dc:date>
    </item>
    <item>
      <title>Re: Output name oddity using FeatureClassToGeodatabase to copy hosted feature layers in AGO</title>
      <link>https://community.esri.com/t5/python-questions/output-name-oddity-using-featureclasstogeodatabase/m-p/1326558#M68543</link>
      <description>&lt;P&gt;If I try to run it in Pro 2.x I get that error as it doesn't appear as if it was added until Pro 3.&lt;/P&gt;&lt;P&gt;R_&lt;/P&gt;</description>
      <pubDate>Thu, 07 Sep 2023 20:14:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/output-name-oddity-using-featureclasstogeodatabase/m-p/1326558#M68543</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2023-09-07T20:14:10Z</dc:date>
    </item>
  </channel>
</rss>

