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) mxd.saveACopy(r"C:\Project\Project_NP.mxd") del mxd
To publish with arcpy read this page of documentation: