Has anyone got a Python script that they are willing to share that only backs up hosted feature layers for either an AGOL organization or ArcGIS Enterprise Deployment. I'm only interested in backing up content that our users have created rather than any referenced feature services as these dataset are backed up via enterprise backups.
I'm trying to remove the issue where users create hosted feature layers and rely on the data without taking manual backups. These users are unaware that AGOL hosted data can't be recovered or that you can't restore a datastore to get one hosted feature layer back.
I've looked at running a notebook however we only have enterprise 10.7.1 so I can't see an easy way of scheduling this task either.
Any help would be appreciated
You can use the ArcGIS Python API in regular python scripts outside of notebooks. You still set it up with the
from arcgis.gis import GIS
gis = GIS("https://www.arcgis.com", "arcgis_python", "P@ssword123")
and then use that gis object to find all the hosted files and make backups in the manner that suits your
items = gis.content.search('Palm Springs Trails') for item in items: <get hosted layer id here with some legendary code>
and then set up the script in windows task manager or as a service.
I can search through some old code I have, but ESRI's examples are pretty good.
and you can install the API through conda:
@JeffKhas the right idea. I'll just add that once you've looped over an item that you want to backup, there functions like export (for GIS data), download (for files), and download_metadata that will help you save the content locally.