以前每每说起ArcSDE的数据迁移都会建议大家使用ArcGIS的方法做迁移,也就是将数据导出到FGDB,然后将FGDB再导入到新的数据库。
ArcSDE数据迁移方法实践说明
http://blog.csdn.net/linghe301/article/details/8556417
关于ArcGIS数据迁移方案的策略
http://blog.csdn.net/linghe301/article/details/6330759
但是上面所推荐的方式都是适用于非ArcSDE版本数据,对ArcSDE版本数据来说,以Oracle数据库为例,如果用户需要备份或者迁移,建议使用的就是纯数据库的方法比如Oracle的数据泵、冷备份、RMAN,但是这些方法技术要求高,那么对ArcSDE的版本化的数据,我们怎么进行备份或者迁移呢?
其实道理很简单,非ArcSDE版本数据,其实可以理解为一个默认版本(虽然不能这样认为),那么我们将该版本下的数据导出来,那么ArcSDE版本数据,我们遍历一下所有的版本(default版本和相关子版本),将所有版本的数据都导出一份,比如每个版本都导出一个FGDB,这些FGDB就是相当于ArcGIS多版本数据的备份,至于迁移,其实是一样的,在一个新的数据库创建相应的子版本,然后将各个版本的数据导入即可。但是这种方法肯定不可能与原库的数据一模一样(这里面的数据不是要素类,是指的版本表的信息),但是至少这是一种对技术要求不高,但是前提只要熟悉ArcSDE版本操作以及桌面导入导出操作即可。
相关步骤
1:获得ArcSDE连接
2:获得ArcSDE连接参数对象
3:获得所有Version的列表对象
4:创建不同版本的ArcSDE新连接
5:循环每一个ArcSDE连接(其实就是对每个版本导出数据)
6:为每一个版本创建一个存储的FGDB
7:循环每个连接的数据集已经要素类,重点使用arcpy.Copy_management的GP工具
8:拷贝完毕后压缩FGDB
相关参考:
# Author : Brandur Sigurjónsson [email protected] # Landmælingar Íslands / National Land Survey of Iceland # Feb-2012 import arcpy, time, sys from datetime import datetime, date from arcpy import env if (len(sys.argv) <> 6) : print "Usage : python export-sde-fgdb.py basepath-ending-with-slash sde-password sde-servername sde-service sde-database" sys.exit() try: start = time.clock() basedir = sys.argv[1] env.workspace = basedir + "defaultconnection/SDE_DEFAULT.sde" versionList = arcpy.ListVersions() fcList = arcpy.ListFeatureClasses() dsList = arcpy.ListDatasets() tbList = arcpy.ListTables() folderName = basedir + "ConnectionFiles" serverName = sys.argv[3] serviceName = sys.argv[4] databaseName = sys.argv[5] authType = "DATABASE_AUTH" username = "sde" password = sys.argv[2] saveUserInfo = "SAVE_USERNAME" saveVersionInfo = "SAVE_VERSION" connFiles = [] baseFilename = datetime.now().strftime("%Y-%m-%d_%H-%M") print "BaseFileDatabaseName: " + baseFilename for version in versionList: fileName = baseFilename + "-VER-" + str(version) fileName = fileName.replace('.','_') fileName = fileName.replace(':','_') fileName = fileName.replace(' ','-') arcpy.CreateArcSDEConnectionFile_management (folderName, fileName, serverName, serviceName, databaseName, authType, username, password, saveUserInfo, version, saveVersionInfo) connFiles.append(fileName) for conn in connFiles: fileGeoDbLocation = basedir + "databases" fileGeoDb = conn + ".gdb" arcpy.CreateFileGDB_management(fileGeoDbLocation, fileGeoDb) env.workspace = folderName + "\\" + conn + ".sde" totaldest = fileGeoDbLocation + "\\" + fileGeoDb + "\\" for lmids in dsList: fcinds = arcpy.ListFeatureClasses("","All",lmids) destds = lmids.replace('.','_') totaldsdest = totaldest + "DS_" + destds # Related feature classes and datasets that get dragged in by others need to be excluded here to avoid duplication error # Replace RELATED_DS whith your dataset # Replace RELATED_FC whith your feature class if (destds <> "RELATED_DS") and (destds.find("RELATED_FC") == -1) : for fccopy in fcinds: srcfc = lmids + "\\" + fccopy destdsfc = fccopy.replace('.','_') totaldsfcdest = totaldsdest + "_FC_" + destdsfc print srcfc + " ----> " + totaldsfcdest arcpy.Copy_management(srcfc, totaldsfcdest,"FeatureClass") for lmifc in fcList: destfc = lmifc.replace('.','_') totalfcdest = totaldest + "DS_ROOT_FC_" + destfc print lmifc + " ----> " + totalfcdest arcpy.Copy_management(lmifc, totalfcdest) # Exporting tables is problematic because of all non-sde tables need to be excluded # for lmitb in tbList: # desttb = lmitb.replace('.','_') # totaltbdest = totaldest+ desttb # # Exclude tables owned by APPQO # if (desttb.find("APPQO") == -1) : # print lmitb + " ----> " + totaltbdest # arcpy.Copy_management(lmitb, totaltbdest) print "Compressing : " + fileGeoDbLocation + "\\" + fileGeoDb arcpy.CompressFileGeodatabaseData_management(fileGeoDbLocation + "\\" + fileGeoDb) elapsed = (time.clock() - start) print "Total time : " + str(elapsed) + " seconds" print "or : " + str(elapsed/60) + " minutes" print "or : " + str(elapsed/3600) + " hours" resultFile = open(basedir + "result.txt","w") resultFile.write("yes") resultFile.close except Exception as e: print e exceptFile = open(basedir + "exception.txt","w") resultFile = open(basedir + "result.txt","w") resultFile.write("no") resultFile.close exceptFile.write(str(e)) exceptFile.close
如果理解版本原理的话,上面的思想不难理解。
缺点:大家都知道,ArcGIS版本是一种状态,快照,不是数据的物理复制,但是上面的思想是将各个版本物理复制化了,虽然最终可以达到恢复的目的,但是无疑增大了冗余数据,而且还需要创建子版本,将相关子版本的数据进行导入。
如果是完整的迁移,对版本数据来说,唯一使用的方法就是数据库的方法。但是如果不熟悉数据库技术的话,上面的方法是可以考虑的。
-------------------------------------------------------------------------------------------------------
版权所有,文章允许转载,但必须以链接方式注明源地址,否则追究法律责任!
------------------------------------------------------------------------------------------------------