Backup Survey 123 Feature Layer

2698
6
Jump to solution
03-29-2021 06:23 AM
DavidMc_Laughlin
New Contributor III

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.

Tags (2)
3 Solutions

Accepted Solutions
DougBrowning
MVP Esteemed Contributor

If you go into the properties of the layer you can Export to a GDB which brings all photos and layers.

DougBrowning_0-1617028166535.png

 

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.

View solution in original post

MarthaRodgers
New Contributor III

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

View solution in original post

DougBrowning
MVP Esteemed Contributor

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.  

View solution in original post

6 Replies
DougBrowning
MVP Esteemed Contributor

If you go into the properties of the layer you can Export to a GDB which brings all photos and layers.

DougBrowning_0-1617028166535.png

 

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.

DavidMc_Laughlin
New Contributor III

Cheers Doug!

0 Kudos
MarthaRodgers
New Contributor III

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

DavidMc_Laughlin
New Contributor III

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.

0 Kudos
DougBrowning
MVP Esteemed Contributor

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.  

DougBrowning
MVP Esteemed Contributor

Sorry just got the bug #BUG-000127047 back.  Been 3 years but looks like it is in plan now at least?

DougBrowning_0-1658784560557.png