Interating through a feature dataset to automate backup

2121
1
07-07-2013 07:36 PM
HanliePretorius
New Contributor III
Hi,

I'm trying to automate the backup of a feature dataset in a GDB on a database server to a GDB on a network drive. The locations of the input feature dataset and the output GDB are hard coded for now.

The model goes through the following steps:

1. Creates a feature dataset on the network drive named 'backup_<yyyymmdd>'

2. Iterates through the feature classess, calculates an output name for each and copies the feature class to the network drive.

My problem is that the model works fine when I set the iterator to use line features only, but when I don't specify or select points, the model stops with the following error:

ERROR 000260: Failed to copy Database Connections\AIA-MSDB02@AIA_GIS@giscreator.sde\AIA_GIS.GISCREATOR.Terminals\AIA_GIS.GISCREATOR.DTB_ANNO into X:\Map Requests\2013\Job2378_Automate_Monthly_Backup\GISBackupTest.gdb\backup_20130708\July082013_DTB_ANNO
The table already exists.

The table 'July082013_DTB_ANNO' does not show up in ArcCatalog and even when I delete the feature dataset and start over, I get the same error.

The model consists of two tools, BackupTerminals, which creates the feature dataset and IterateTerminals, which iterates through the feature classes in the source and copies them to the destination under new names:

# ---------------------------------------------------------------------------
# BackupTerminals.py
# Created on: 2013-07-08 15:27:34.00000
#   (generated by ArcGIS/ModelBuilder)
# Usage: Backup Terminals <backup_terminalsBackupDate_> <GISBackupTest_gdb> 
# Description: 
# ---------------------------------------------------------------------------

# Import arcpy module
import arcpy

# Load required toolboxes
arcpy.ImportToolbox("X:/Map Requests/2013/Job2378_Automate_Monthly_Backup/AutomateBackup.tbx")

# Script arguments
backup_terminalsBackupDate_ = arcpy.GetParameterAsText(0)
if backup_terminalsBackupDate_ == '#' or not backup_terminalsBackupDate_:
    backup_terminalsBackupDate_ = "X:\\Map Requests\\2013\\Job2378_Automate_Monthly_Backup\\GISBackupTest.gdb\\backup%terminalsBackupDate%" # provide a default value if unspecified

GISBackupTest_gdb = arcpy.GetParameterAsText(1)
if GISBackupTest_gdb == '#' or not GISBackupTest_gdb:
    GISBackupTest_gdb = "X:\\Map Requests\\2013\\Job2378_Automate_Monthly_Backup\\GISBackupTest.gdb" # provide a default value if unspecified

# Local variables:
terminalsBackupDate = "_20130708"

# Process: Calculate Terminals Backup Date
arcpy.CalculateValue_management("time.strftime(\"_%Y%m%d\")", "", "String")

# Process: Create Feature Dataset
arcpy.CreateFeatureDataset_management(GISBackupTest_gdb, "backup%terminalsBackupDate%", "PROJCS['NZGD_2000_New_Zealand_Transverse_Mercator',GEOGCS['GCS_NZGD_2000',DATUM['D_NZGD_2000',SPHEROID['GRS_1980',6378137.0,298.257222101]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Transverse_Mercator'],PARAMETER['False_Easting',1600000.0],PARAMETER['False_Northing',10000000.0],PARAMETER['Central_Meridian',173.0],PARAMETER['Scale_Factor',0.9996],PARAMETER['Latitude_Of_Origin',0.0],UNIT['Meter',1.0]];-4020900 1900 10000;-100000 10000;-100000 10000;0.001;0.001;0.001;IsHighPrecision")

# Process: IterateTerminals
arcpy.gp.toolbox = "X:/Map Requests/2013/Job2378_Automate_Monthly_Backup/AutomateBackup.tbx";
# Warning: the toolbox X:/Map Requests/2013/Job2378_Automate_Monthly_Backup/AutomateBackup.tbx DOES NOT have an alias. 
# Please assign this toolbox an alias to avoid tool name collisions
# And replace arcpy.gp.Model1(...) with arcpy.Model1_ALIAS(...)
arcpy.gp.Model1(terminalsBackupDate)


# ---------------------------------------------------------------------------
# IterateTerminals.py
# Created on: 2013-07-08 15:28:04.00000
#   (generated by ArcGIS/ModelBuilder)
# Usage: IterateTerminals <date> 
# Description: 
# ---------------------------------------------------------------------------

# Import arcpy module
import arcpy

# Load required toolboxes
arcpy.ImportToolbox("Model Functions")

# Script arguments
date = arcpy.GetParameterAsText(0)
if date == '#' or not date:
    date = "_YYYYMMDD" # provide a default value if unspecified

# Local variables:
AIA_GIS_GISCREATOR_Terminals = "Database Connections\\AIA-MSDB02@AIA_GIS@giscreator.sde\\AIA_GIS.GISCREATOR.Terminals"
v_tableName_ = date
terminalLayer = "Database Connections\\AIA-MSDB02@AIA_GIS@giscreator.sde\\AIA_GIS.GISCREATOR.Terminals\\AIA_GIS.GISCREATOR.DTB_ANNO"

# Process: Iterate Feature Classes
arcpy.IterateFeatureClasses_mb(AIA_GIS_GISCREATOR_Terminals, "", "POINT", "NOT_RECURSIVE")

# Process: Calculate Value
arcpy.CalculateValue_management("getname(\"%Name%\")", "def getname(name):\\n  import datetime\\n  return time.strftime(\"%B%d%Y_\") + name.replace(\"AIA_GIS.GISCREATOR.\",\"\")\\n", "Variant")

# Process: Copy
arcpy.Copy_management(terminalLayer, v_tableName_, "")


Can someone perhaps see why the model fails on point type feature classes? Or is the error message a red herring and something else is going on?

Thanks
Hanlie
0 Kudos
1 Reply
HanliePretorius
New Contributor III
For some reason, when I replaced the 'Copy' tool with 'Copy Features' the model works.

Cheers
Hanlie
0 Kudos