I have an ArcSDE GDB that looks something like this:
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
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.