Skip to main content
deleted 57 characters in body
Source Link
Chad
  • 85
  • 1
  • 5

I worked through the problem and found a solution. Im not sure if its appropriate to answer my own question or edit my question to show the solution. I will keep it here unless told otherwise. Im new toalso revised the group and not current on allcode to copy ALL feature classes in the proceduresWATER dataset, instead of listing each one individually.

# Name: CreateGDBBackupGDB.py
# Description: Create a file GDB

# Import system modules
import arcpy
from arcpy import env # WAS MISSING IN ORIGINAL POST
import datetime

out_folder_path = "w:/GISDATA/Database_Backups"
nowstart = datetime.datetime.now()
YearMonthDay = nowstart.strftime("%Y_%m_%d")
out_name = "TEST_WSdata_" + YearMonthDay + ".gdb"

# Execute CreateFileGDB
arcpy.CreateFileGDB_management(out_folder_path, out_name)


# Set environment settings
env.workspace =    "C:\Users\cbgibson\AppData\Roaming\ESRI\Desktop10.2\ArcCatalog\TEST_WSdata.sde"

# Set local variables
inFeatureswaterFC = ['WATERLINES'arcpy.ListFeatureClasses("", 'GRAVITY']"", "WATER") #CHANGED TO INCLUDE ALL FEATURE CLASSES IN THE WATER DATASET
outLocation = "w:/GISDATA/Database_Backups/" +"TEST_WSdata_" + YearMonthDay + ".gdb" 

# Execute TableToGeodatabase
for fc in waterFC:
    arcpy.FeatureClassToGeodatabase_conversion(inFeaturesfc, outLocation)

I worked through the problem and found a solution. Im not sure if its appropriate to answer my own question or edit my question to show the solution. I will keep it here unless told otherwise. Im new to the group and not current on all the procedures.

# Name: CreateGDB.py
# Description: Create a file GDB

# Import system modules
import arcpy
from arcpy import env
import datetime

out_folder_path = "w:/GISDATA/Database_Backups"
nowstart = datetime.datetime.now()
YearMonthDay = nowstart.strftime("%Y_%m_%d")
out_name = "TEST_WSdata_" + YearMonthDay + ".gdb"

# Execute CreateFileGDB
arcpy.CreateFileGDB_management(out_folder_path, out_name)


# Set environment settings
env.workspace =    "C:\Users\cbgibson\AppData\Roaming\ESRI\Desktop10.2\ArcCatalog\TEST_WSdata.sde"

# Set local variables
inFeatures = ['WATERLINES', 'GRAVITY']
outLocation = "w:/GISDATA/Database_Backups/" +"TEST_WSdata_" + YearMonthDay + ".gdb" 

# Execute TableToGeodatabase
arcpy.FeatureClassToGeodatabase_conversion(inFeatures, outLocation)

I worked through the problem and found a solution. I also revised the code to copy ALL feature classes in the WATER dataset, instead of listing each one individually.

# Name: BackupGDB.py
# Description: Create a file GDB

# Import system modules
import arcpy
from arcpy import env # WAS MISSING IN ORIGINAL POST
import datetime

out_folder_path = "w:/GISDATA/Database_Backups"
nowstart = datetime.datetime.now()
YearMonthDay = nowstart.strftime("%Y_%m_%d")
out_name = "TEST_WSdata_" + YearMonthDay + ".gdb"

# Execute CreateFileGDB
arcpy.CreateFileGDB_management(out_folder_path, out_name)


# Set environment settings
env.workspace = "C:\Users\cbgibson\AppData\Roaming\ESRI\Desktop10.2\ArcCatalog\TEST_WSdata.sde"

# Set local variables
waterFC = arcpy.ListFeatureClasses("", "", "WATER") #CHANGED TO INCLUDE ALL FEATURE CLASSES IN THE WATER DATASET
outLocation = "w:/GISDATA/Database_Backups/" +"TEST_WSdata_" + YearMonthDay + ".gdb" 

# Execute TableToGeodatabase
for fc in waterFC:
    arcpy.FeatureClassToGeodatabase_conversion(fc, outLocation)
Post Undeleted by Chad
Post Deleted by Chad
Source Link
Chad
  • 85
  • 1
  • 5

I worked through the problem and found a solution. Im not sure if its appropriate to answer my own question or edit my question to show the solution. I will keep it here unless told otherwise. Im new to the group and not current on all the procedures.

# Name: CreateGDB.py
# Description: Create a file GDB

# Import system modules
import arcpy
from arcpy import env
import datetime

out_folder_path = "w:/GISDATA/Database_Backups"
nowstart = datetime.datetime.now()
YearMonthDay = nowstart.strftime("%Y_%m_%d")
out_name = "TEST_WSdata_" + YearMonthDay + ".gdb"

# Execute CreateFileGDB
arcpy.CreateFileGDB_management(out_folder_path, out_name)


# Set environment settings
env.workspace =    "C:\Users\cbgibson\AppData\Roaming\ESRI\Desktop10.2\ArcCatalog\TEST_WSdata.sde"

# Set local variables
inFeatures = ['WATERLINES', 'GRAVITY']
outLocation = "w:/GISDATA/Database_Backups/" +"TEST_WSdata_" + YearMonthDay + ".gdb" 

# Execute TableToGeodatabase
arcpy.FeatureClassToGeodatabase_conversion(inFeatures, outLocation)