Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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?

UPDATE:

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.

share|improve this question
    
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 Feb 14 '13 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 :) –  Mapbert Feb 14 '13 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 Feb 14 '13 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 Feb 14 '13 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 Feb 14 '13 at 20:01
add comment

1 Answer

up vote 2 down vote accepted

This Question seems to suggest a solution to your problem because its asker 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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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