目前oss数据迁移工具不支持华为云的OBS。所以通过http的方式进行迁移。

1. 主要思路

把obs里面所有对象的路径列到文件里面去,然后通过ossimport工具以http方式进行迁移

2. 列出所有对象的路径

先通过pip安装sdk

pip install esdk-obs-python 

python方式获取所有文件路径的方法

from obs import ObsClient


url='https://xx.obs.xxx.myhuaweicloud.com/' #华为云OBS公网访问地址

obsClient = ObsClient(
		access_key_id='key', #obs的keyid
		secret_access_key='secret',#obs的key
		server='https://obs.cn-north-1.myhuaweicloud.com'  #地区
)
marker = '1'


def get_all():
		global marker,url
		file = './http.list'  #保存obs所有文件的文件
		clear_file = open(file, 'w')

		while marker:
				if marker == '1':
						marker = None
				resp = obsClient.listObjects('bucket名称',marker=marker) #OBS的名称
				if resp.status < 300:
						index = 1
						with open(file,'a') as f:
								for content in resp.body.contents:
										http = url+'    '+content.key
										f.write(http)
										f.write('\n')
										index += 1
						marker = resp.body.next_marker
				else:
						print('errorCode:', resp.errorCode)
						print('errorMessage:', resp.errorMessage)

if __name__ == '__main__':
		get_all()

3. ossimport工具迁移

ossimport下载地址:https://help.aliyun.com/document_detail/56990.html?spm=a2c4g.11174283.6.901.408d7da2ZbUTyR

需要修改的配置

srcType=http  //源方式
#目的 access key
destAccessKey=xx
#目的 secret key
destSecretKey=xxx
#目的endpoint,请根据您的实际oss区域填写,默认为杭州的域名,如果用阿里云ecs虚拟机做迁移的,请使用internal域名,不计费且不受虚拟机带宽限制(非虚拟机无法使用);例:http://oss-cn-hangzhou-internal.aliyuncs.com
#注意:域名里不要带上bucket前缀,oss域名帮助页面:https://help.aliyun.com/document_detail/31837.html
destDomain=http://oss-cn-shanghai.aliyuncs.com
#第二步获取到的所有对象的路径url
httpListFilePath=G:/www/obs/http.list

执行脚本就ok了