I have two ArcGIS Server instances, one is development and the other is production. I've copied the MXDs and .msds from my ArcGISServer folder on server one to server two for back up. Instead of manually going into my mxds on server two and setting the data source then publishing, is there a method to complete this task with ArcPy?


With arcpy use the following method to replace workspace of your mxd:

import arcpy
mxd = arcpy.mapping.MapDocument(r"C:\Project\Project_default.mxd")
mxd.findAndReplaceWorkspacePaths(r"C:\Project\Connection with password info saved.sde", 
                                 r"C:\Project\Connection with no password info saved.sde", False)
del mxd

To publish with arcpy read this page of documentation:

Publish a map service from a map document (MXD)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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