I have an ArcSDE GDB that looks something like this:

++ GDB
+++++ Dataset1
++++++++ FeatureClass1
++++++++ FeatureClass2
+++++ Dataset2
++++++++ FeatureClass3
++++++++ FeatureClass4
+++++ Table
+++++ Table_FeatureClass1_RelationshipClass
+++++ Table_FeatureClass3_RelationshipClass

I wanted to create a backup of the two datasets as follows:

arcpy.Copy_management('C:/GDB.sde/Dataset1', 'C:/Extract.gdb/Dataset1')
arcpy.Copy_management('C:/GDB.sde/Dataset2', 'C:/Extract.gdb/Dataset2')

The problem is that when I run the first statement it automatically copies Table and all related classes, including FeatureClass3 from Dataset2. Then, when it gets to the second line, the script fails because it's trying to create Dataset2 which already exists. It doesn't give a specific error, but when I remove the relationship classes everything works fine. So does anyone know how to copy multiple datasets that share a related table like this?


Following blah238's comment below, I tried using the Export XML Workspace tool with the SDE connection as the input, and a local XML file as the output. It ran fine for most of the datasets, and then hit one it didn't like an threw an error 999999: Failed to execute. I don't see anything peculiar about the dataset, other than it's empty and not registered as versioned. I then tried exporting each of the two datasets individually, which worked but was quite slow and added a few hundred MB to the total file size. Not really a practical solution.

Also, I found this ArcGIS Forums post describing the same issue. There's an explanation of how to list FC's that participate in relationship classes, so I could potentially check against that before trying to copy.

  • Which version of ArcGIS are you at? At 10.1 the Import/Export XML Workspace Document tools could come in handy. Is this something that you need to automate or is a manual process acceptable?
    – blah238
    Commented Feb 14, 2013 at 4:07
  • I'm on 10.1 - the XML tool looked like a good bet, but one of our datasets is throwing error 999999: Failed to execute. This does have to be automated, otherwise I would resort to quicker and dirtier means :)
    – bertday
    Commented Feb 14, 2013 at 19:07
  • What steps did you take that resulted in that error? You can edit your question to add these details instead of the comments.
    – blah238
    Commented Feb 14, 2013 at 19:14
  • BTW, I wasn't suggesting these tools alone would be enough to do the job. You still have the issue of wanting to be selective in what you copy, so the XML would have to be parsed and unwanted sections removed. This could be done programmatically but I am not sure how difficult it would be.
    – blah238
    Commented Feb 14, 2013 at 19:21
  • I would suggest using the schema only option on the Import/Export tools and only load the actual data after the empty schema has been created. You can use the Append tool for this.
    – blah238
    Commented Feb 14, 2013 at 20:01

1 Answer 1


Copying entire geodatabase with relationship classes and domains and reproject all feature classes from wgs84 to state plane? seems to suggest a solution to your problem because it says that using the Feature Class To Feature Class tool "lost all of the relationships and tables".

I've not tested this but would expect that you will also need to insert a Create Feature Dataset step into the process to get the desired output geodatabase schema.

If this proves slow then perhaps experiment with copying the whole geodatabase and then deleting its unwanted components - this may or may not be viable and quicker.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.