<?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 Backup AGO Feature Layers Using Notebook for Organization in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/backup-ago-feature-layers-using-notebook-for/m-p/1239117#M49237</link>
    <description>&lt;P&gt;The following inputs will backup all feature layers in the Organization. A zip file is created for each feature layer and saved to the directory /arcgis/home.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Input 1&lt;/P&gt;&lt;P&gt;from arcgis.gis import GIS&lt;BR /&gt;import datetime as dt&lt;BR /&gt;gis = GIS('home')&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Input 2&lt;/P&gt;&lt;P&gt;org_users = gis.users.search(query = '*', max_users = 10000)&lt;BR /&gt;print(f'{len(org_users)} users found')&lt;BR /&gt;org_users[:]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Input 3&lt;/P&gt;&lt;P&gt;org_content = []&lt;/P&gt;&lt;P&gt;for user in org_users:&lt;BR /&gt;qe = f"type:Feature Service, owner: {user.username}"&lt;BR /&gt;user_content = gis.content.advanced_search(query=qe, max_items=-1)['results']&lt;BR /&gt;org_content += user_content&lt;BR /&gt;&lt;BR /&gt;print(f"{len(org_content)} items found in org")&lt;BR /&gt;print(org_content)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Input 4&lt;/P&gt;&lt;P&gt;folder_path = ('home')&lt;BR /&gt;items = org_content&lt;BR /&gt;print(items)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Input 5&lt;/P&gt;&lt;P&gt;def download_as_fgdb(item_list, backup_location):&lt;BR /&gt;for item in item_list:&lt;BR /&gt;try:&lt;BR /&gt;if 'View Service' in item.typeKeywords:&lt;BR /&gt;print(item.title + " is view, not downloading")&lt;BR /&gt;else:&lt;BR /&gt;print("Downloading " + item.title)&lt;BR /&gt;version = dt.datetime.now().strftime("%d_%b_%Y")&lt;BR /&gt;result = item.export(item.title + "_" + version, "File Geodatabase")&lt;BR /&gt;result.download(backup_location)&lt;BR /&gt;result.delete()&lt;BR /&gt;print("Successfully downloaded " + item.title)&lt;BR /&gt;except:&lt;BR /&gt;print("An error occurred downloading " + item.title)&lt;BR /&gt;print("The function has completed")&lt;/P&gt;&lt;P&gt;download_as_fgdb(items, folder_path)&lt;/P&gt;</description>
    <pubDate>Thu, 08 Dec 2022 13:48:15 GMT</pubDate>
    <dc:creator>ChristopherMask</dc:creator>
    <dc:date>2022-12-08T13:48:15Z</dc:date>
    <item>
      <title>Backup AGO Feature Layers Using Notebook for Organization</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/backup-ago-feature-layers-using-notebook-for/m-p/1239117#M49237</link>
      <description>&lt;P&gt;The following inputs will backup all feature layers in the Organization. A zip file is created for each feature layer and saved to the directory /arcgis/home.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Input 1&lt;/P&gt;&lt;P&gt;from arcgis.gis import GIS&lt;BR /&gt;import datetime as dt&lt;BR /&gt;gis = GIS('home')&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Input 2&lt;/P&gt;&lt;P&gt;org_users = gis.users.search(query = '*', max_users = 10000)&lt;BR /&gt;print(f'{len(org_users)} users found')&lt;BR /&gt;org_users[:]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Input 3&lt;/P&gt;&lt;P&gt;org_content = []&lt;/P&gt;&lt;P&gt;for user in org_users:&lt;BR /&gt;qe = f"type:Feature Service, owner: {user.username}"&lt;BR /&gt;user_content = gis.content.advanced_search(query=qe, max_items=-1)['results']&lt;BR /&gt;org_content += user_content&lt;BR /&gt;&lt;BR /&gt;print(f"{len(org_content)} items found in org")&lt;BR /&gt;print(org_content)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Input 4&lt;/P&gt;&lt;P&gt;folder_path = ('home')&lt;BR /&gt;items = org_content&lt;BR /&gt;print(items)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Input 5&lt;/P&gt;&lt;P&gt;def download_as_fgdb(item_list, backup_location):&lt;BR /&gt;for item in item_list:&lt;BR /&gt;try:&lt;BR /&gt;if 'View Service' in item.typeKeywords:&lt;BR /&gt;print(item.title + " is view, not downloading")&lt;BR /&gt;else:&lt;BR /&gt;print("Downloading " + item.title)&lt;BR /&gt;version = dt.datetime.now().strftime("%d_%b_%Y")&lt;BR /&gt;result = item.export(item.title + "_" + version, "File Geodatabase")&lt;BR /&gt;result.download(backup_location)&lt;BR /&gt;result.delete()&lt;BR /&gt;print("Successfully downloaded " + item.title)&lt;BR /&gt;except:&lt;BR /&gt;print("An error occurred downloading " + item.title)&lt;BR /&gt;print("The function has completed")&lt;/P&gt;&lt;P&gt;download_as_fgdb(items, folder_path)&lt;/P&gt;</description>
      <pubDate>Thu, 08 Dec 2022 13:48:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/backup-ago-feature-layers-using-notebook-for/m-p/1239117#M49237</guid>
      <dc:creator>ChristopherMask</dc:creator>
      <dc:date>2022-12-08T13:48:15Z</dc:date>
    </item>
  </channel>
</rss>

