I would like to make an exact copy (domains, feature datasets, feature classes, etc.) of an SDE database to a file geodatabase.
I have tried several possibilities, including:
- using the Copy (Data Management) process
- creating a new GDB and manually copying each feature dataset from
the SDE - exporting an xml workspace document from the SDE and importing it
into the GDB
The Copy_management
process does not seem like it would work for copying an SDE to a GDB, since the input and output data types must match.
The process of importing each feature dataset into a new GDB could probably be automated using Copy_management as well by iterating through each feature dataset, though it seems this could cause problems of an incomplete copy if there was an error with one of the processes.
Exporting and importing xml workspaces seems to work, though this process creates incredibly large files when the process is used on large geodatabases.
Is there a more straightforward way to copy the contents and schema of an SDE to a GDB than the ways mentioned, in a way that can be automated?
If not, are there any reasons that the above possibilities should not be used in this process?
Best Answer
I know this post is a little old but I though I would share my answer since I was faced with the same issue. The following script SHOULD copy all tables, feature classes and relationships not in a dataset and also will copy over all datasets including the feature classes, topology, etc within the dataset. It will skip over any errors durring the copy adn keep going. It will produce a log file that contains data such as the source DB item count and the destination item count so you can compare the copy and it will log errors it encounters as well.
I had really good luck with this. I was replicating an SDE database to a file geodatabase. I haven't done too extensive of testing on this script though since it fulfilled all my needs. I tested it using ArcGIS 10.3. Also, one thing to note, I was in talks with someone that has used this script and they ran into an issue with an error copying certain datasets due to improper permissions and empty tables.
Lemur - why not create your relationships based to a global id instead of the object id? That you your relationships would be preserved. If you haven't created global id's I would highly recommend it.
-update
I added a little more logic into the code to handle bad database connection paths and better logging and error handling: