Question

How to have a daily back up of an ArcGIS feature layer?

  • 3 May 2022
  • 1 reply
  • 35 views

Badge +7

I have an ArcGIS feature layer with two tables that I'd like to backup daily. I've created workspace with two readers and two writers. The Esri ArcGIS Online (AGOL) Feature Service Readers read from the two tables. The Esri Geodatabase (File Geodb) Writers write to the same geodatabase (.gdb) folder.

 

This works great. For the GeoDB writer I'm using Insert for the feature operation to append rows onto the destination table. Since I'm writing to the same GeoDB folder, over time I don't think that this is not the same as creating a copy. I'd like to try to append the date to the file name such as fileName_220503 for today so that I have a new gdb folder. I'm not sure how to do that. Ideally, storing no more than 30 or 60 days of backups would be best. So, maybe appending a number (instead of a date) would be better.

 

I plan to run this from the Windows Task Scheduler (which I have not used before). I'm not sure how to limit the number of backups to 30 or 60 folders. Any thoughts or suggestions on how to dynamically name the gdb folder or limit the number of backups would be great. Thank you.


1 reply

You may want to control the backup operation inside of the batch file itself. I would run xcopy on the .gdb folder, and then run the FME script to then overwrite the .gdb rather than appending to it. Your code might look something like this:

set source="C:\Reference\GIS.gdb"
set datename=%date:~-4,4%_%date:~-7,2%_%date:~-10,2%
set destination="C:\Archives\GIS_Backup_%datename%.gdb"
xcopy /i /e /y %source% %destination%
 
FME "C:\FME\FME_AGOL_To_FGDB.fmw"

/i on the xcopy forces the .gdb to be copied as a directory, /e copies all empty sub directories (may not be needed for .gdb), and /y suppresses overwrite prompts.

 

If you only want 30 or so backups, you could just use %date:~-10,2% to grab the day of the month; it's not perfect, but it should work well enough. If you go this route, you will want to delete the old backup .gdb as the file structure inside of the old .gdb may not match the new one.

Reply