Hi,
Has anyone came across an effective way to backup a Survey 123 Feature Layer, including photos?
I've tried the AGOL assistant to copy to AGOL and Portal. However, the attachments aren't carried across.
I've also tried this using FME unsuccessfully.
Thanks, David.
Solved! Go to Solution.
If you go into the properties of the layer you can Export to a GDB which brings all photos and layers.
I have a ArcPro python script that does it. Grabs the last logged in user from Pro. I schedule it as a batch file that runs every night.
import os, time
from arcgis.gis import GIS
# Setup inputs
configFile = r"BackupTerrestrial2021.txt"
backupDir = r"your path"
# Make a connection to ArcPro
# only use this one if security issues
#gis = GIS('pro',verify_cert=False)
# preferred
gis = GIS('pro')
# read in the config file for list of HFS for Survey123
BackupAllAGOHFSConfigFile = open(configFile, 'r')
HFSList = BackupAllAGOHFSConfigFile.read().splitlines()
BackupAllAGOHFSConfigFile.close()
for HFS in HFSList:
HFSname = HFS.split(",")[0]
itemId = HFS.split(",")[1] # this now comes from the main AGO page with all the settings.
# Start the export to GDB job
print ("Export job started for " + HFSname)
fsLink = gis.content.get(itemId)
result = fsLink.export("tempOut"+ HFSname, "File Geodatabase")
# Save to file system
dt = time.strftime("%Y%m%d_%H%M%S")
out_file = os.path.join(backupDir,"{}_{}.zip".format(HFSname,dt))
print ("Saving final downloaded FGDB to {}...".format(out_file))
result.download(backupDir, out_file)
# Remove the extracted FGDB from AGOL (cleanup)
print ("Removing the export file from AGOL")
deleteResult = result.delete()
print ("Delete result is " + str(deleteResult))
I use as config file so I can download several diff services. Just give it a name to call the backup and the Item ID.
Testing222,87858c26de5e4cdca32958a5870667e1
Also have a ArcRest based one that just needs ArcMap level python but then it gets complicated depending on your security which may require packages. Let me know if you want that one.
Edit: Note found out only the owner of the service can run this. No idea why.
Hope that helps.
Hi David, that GDB recommendation above may work great, but I ended up following these instructions when I did it in January.
https://support.esri.com/en/technical-article/000012232
Summary:
Create REPLICA of feature service and download that.
-Martha
Note I am currently working on a ticket with Esri now. For the last few years once a service hits 10GB the script starts failing.
If you go into the properties of the layer you can Export to a GDB which brings all photos and layers.
I have a ArcPro python script that does it. Grabs the last logged in user from Pro. I schedule it as a batch file that runs every night.
import os, time
from arcgis.gis import GIS
# Setup inputs
configFile = r"BackupTerrestrial2021.txt"
backupDir = r"your path"
# Make a connection to ArcPro
# only use this one if security issues
#gis = GIS('pro',verify_cert=False)
# preferred
gis = GIS('pro')
# read in the config file for list of HFS for Survey123
BackupAllAGOHFSConfigFile = open(configFile, 'r')
HFSList = BackupAllAGOHFSConfigFile.read().splitlines()
BackupAllAGOHFSConfigFile.close()
for HFS in HFSList:
HFSname = HFS.split(",")[0]
itemId = HFS.split(",")[1] # this now comes from the main AGO page with all the settings.
# Start the export to GDB job
print ("Export job started for " + HFSname)
fsLink = gis.content.get(itemId)
result = fsLink.export("tempOut"+ HFSname, "File Geodatabase")
# Save to file system
dt = time.strftime("%Y%m%d_%H%M%S")
out_file = os.path.join(backupDir,"{}_{}.zip".format(HFSname,dt))
print ("Saving final downloaded FGDB to {}...".format(out_file))
result.download(backupDir, out_file)
# Remove the extracted FGDB from AGOL (cleanup)
print ("Removing the export file from AGOL")
deleteResult = result.delete()
print ("Delete result is " + str(deleteResult))
I use as config file so I can download several diff services. Just give it a name to call the backup and the Item ID.
Testing222,87858c26de5e4cdca32958a5870667e1
Also have a ArcRest based one that just needs ArcMap level python but then it gets complicated depending on your security which may require packages. Let me know if you want that one.
Edit: Note found out only the owner of the service can run this. No idea why.
Hope that helps.
Cheers Doug!
Hi David, that GDB recommendation above may work great, but I ended up following these instructions when I did it in January.
https://support.esri.com/en/technical-article/000012232
Summary:
Create REPLICA of feature service and download that.
-Martha
Hi Martha,
Thanks for sending this on. I tried the method above which sufficed for what I was doing as I was appending data to a Survey 123 FL. But, the above is worth knowing about for future projects.
Cheers, David.
Note I am currently working on a ticket with Esri now. For the last few years once a service hits 10GB the script starts failing.
Sorry just got the bug #BUG-000127047 back. Been 3 years but looks like it is in plan now at least?