企业级软件开发服务商,为企业级客户提供定制软件开发及解决方案服务!

热线:028-68761216 18108129768

yapi的数据的迁移和备份

2020-01-30 733 次
分类: 技术博客

最近因为阿里云的服务器到期,需要迁移到华为云上去。但是之前很多软件开发项目的api的数据都在服务器上,这里我们就需要全量备份迁移到新新服务器。小伙伴的们编写接口文档也是比较辛苦的。

原因很简单,就是为了降低软件开发测试运维成本,华为云新用户有优惠。yapi不需要按着官网文档再次安装那一套,直接压缩拷贝到目标服务器后,然后在mongodb下创建yapi数据库实例。然后我们重要说下数据备份部分。

第一步,备份现有的数据

[root@iZuf692ot9nf1r9fn1unojZ ~]# mongodump -h localhost  -d yapi 

2020-01-19T23:43:43.653+0800    writing yapi.log to 

2020-01-19T23:43:43.654+0800    writing yapi.interface to 

2020-01-19T23:43:43.654+0800    writing yapi.statis_mock to 

2020-01-19T23:43:43.654+0800    writing yapi.interface_cat to 

2020-01-19T23:43:43.671+0800    done dumping yapi.statis_mock (507 documents)

2020-01-19T23:43:43.671+0800    writing yapi.group to 

2020-01-19T23:43:43.671+0800    done dumping yapi.interface (651 documents)

2020-01-19T23:43:43.671+0800    writing yapi.user to 

2020-01-19T23:43:43.671+0800    done dumping yapi.interface_cat (74 documents)

2020-01-19T23:43:43.671+0800    writing yapi.interface_col to 

2020-01-19T23:43:43.672+0800    done dumping yapi.group (50 documents)

2020-01-19T23:43:43.672+0800    writing yapi.identitycounters to 

2020-01-19T23:43:43.673+0800    done dumping yapi.interface_col (16 documents)

2020-01-19T23:43:43.673+0800    writing yapi.project to 

2020-01-19T23:43:43.673+0800    done dumping yapi.identitycounters (15 documents)

2020-01-19T23:43:43.673+0800    writing yapi.token to 

2020-01-19T23:43:43.674+0800    done dumping yapi.project (15 documents)

2020-01-19T23:43:43.674+0800    writing yapi.avatar to 

2020-01-19T23:43:43.674+0800    done dumping yapi.token (14 documents)

2020-01-19T23:43:43.674+0800    writing yapi.follow to 

2020-01-19T23:43:43.677+0800    done dumping yapi.avatar (3 documents)

2020-01-19T23:43:43.677+0800    writing yapi.interface_case to 

2020-01-19T23:43:43.677+0800    done dumping yapi.follow (2 documents)

2020-01-19T23:43:43.677+0800    writing yapi.wiki to 

2020-01-19T23:43:43.678+0800    done dumping yapi.wiki (0 documents)

2020-01-19T23:43:43.678+0800    writing yapi.adv_mock to 

2020-01-19T23:43:43.678+0800    done dumping yapi.interface_case (2 documents)

2020-01-19T23:43:43.678+0800    writing yapi.adv_mock_case to 

2020-01-19T23:43:43.679+0800    done dumping yapi.adv_mock (0 documents)

2020-01-19T23:43:43.679+0800    done dumping yapi.adv_mock_case (0 documents)

2020-01-19T23:43:43.682+0800    done dumping yapi.user (38 documents)

2020-01-19T23:43:43.750+0800    done dumping yapi.log (4148 documents)

第二步,把备份后的文件打包压缩,拷贝到目标服务器。

第三步,还原数据库

[root@iZbp187tgql748sa0udwgrZ server]# mongorestore -d yapi  /www/backup/mongodb/yapi

2020-01-19T23:42:32.142+0800    the --db and --collection args should only be used when restoring from a BSON file. Other uses are deprecated and will not exist in the future; use --nsInclude instead

2020-01-19T23:42:32.142+0800    building a list of collections to restore from /www/backup/mongodb/yapi dir

2020-01-19T23:42:32.159+0800    reading metadata for yapi.log from /www/backup/mongodb/yapi/log.metadata.json

2020-01-19T23:42:32.159+0800    reading metadata for yapi.interface from /www/backup/mongodb/yapi/interface.metadata.json

2020-01-19T23:42:32.159+0800    reading metadata for yapi.avatar from /www/backup/mongodb/yapi/avatar.metadata.json

2020-01-19T23:42:32.159+0800    reading metadata for yapi.statis_mock from /www/backup/mongodb/yapi/statis_mock.metadata.json

2020-01-19T23:42:32.160+0800    restoring yapi.statis_mock from /www/backup/mongodb/yapi/statis_mock.bson

2020-01-19T23:42:32.175+0800    restoring yapi.log from /www/backup/mongodb/yapi/log.bson

2020-01-19T23:42:32.236+0800    restoring yapi.interface from /www/backup/mongodb/yapi/interface.bson

2020-01-19T23:42:32.252+0800    restoring yapi.avatar from /www/backup/mongodb/yapi/avatar.bson

2020-01-19T23:42:32.278+0800    restoring indexes for collection yapi.statis_mock from metadata

2020-01-19T23:42:32.279+0800    restoring indexes for collection yapi.interface from metadata

2020-01-19T23:42:32.280+0800    restoring indexes for collection yapi.avatar from metadata

2020-01-19T23:42:32.280+0800    finished restoring yapi.statis_mock (507 documents)

2020-01-19T23:42:32.280+0800    reading metadata for yapi.project from /www/backup/mongodb/yapi/project.metadata.json

2020-01-19T23:42:32.372+0800    finished restoring yapi.interface (651 documents)

2020-01-19T23:42:32.373+0800    reading metadata for yapi.interface_cat from /www/backup/mongodb/yapi/interface_cat.metadata.json

2020-01-19T23:42:32.384+0800    restoring yapi.project from /www/backup/mongodb/yapi/project.bson

2020-01-19T23:42:32.394+0800    finished restoring yapi.avatar (3 documents)

2020-01-19T23:42:32.394+0800    reading metadata for yapi.user from /www/backup/mongodb/yapi/user.metadata.json

2020-01-19T23:42:32.405+0800    restoring indexes for collection yapi.project from metadata

2020-01-19T23:42:32.405+0800    restoring yapi.interface_cat from /www/backup/mongodb/yapi/interface_cat.bson

2020-01-19T23:42:32.424+0800    restoring yapi.user from /www/backup/mongodb/yapi/user.bson

2020-01-19T23:42:32.449+0800    finished restoring yapi.project (15 documents)

2020-01-19T23:42:32.449+0800    reading metadata for yapi.group from /www/backup/mongodb/yapi/group.metadata.json

2020-01-19T23:42:32.449+0800    restoring indexes for collection yapi.user from metadata

2020-01-19T23:42:32.449+0800    restoring indexes for collection yapi.interface_cat from metadata

2020-01-19T23:42:32.469+0800    finished restoring yapi.user (38 documents)

2020-01-19T23:42:32.469+0800    reading metadata for yapi.interface_col from /www/backup/mongodb/yapi/interface_col.metadata.json

2020-01-19T23:42:32.483+0800    restoring yapi.group from /www/backup/mongodb/yapi/group.bson

2020-01-19T23:42:32.501+0800    restoring yapi.interface_col from /www/backup/mongodb/yapi/interface_col.bson

2020-01-19T23:42:32.520+0800    restoring indexes for collection yapi.group from metadata

2020-01-19T23:42:32.521+0800    restoring indexes for collection yapi.interface_col from metadata

2020-01-19T23:42:32.521+0800    finished restoring yapi.interface_cat (74 documents)

2020-01-19T23:42:32.521+0800    reading metadata for yapi.identitycounters from /www/backup/mongodb/yapi/identitycounters.metadata.json

2020-01-19T23:42:32.521+0800    restoring yapi.identitycounters from /www/backup/mongodb/yapi/identitycounters.bson

2020-01-19T23:42:32.549+0800    no indexes to restore

2020-01-19T23:42:32.549+0800    finished restoring yapi.identitycounters (15 documents)

2020-01-19T23:42:32.549+0800    reading metadata for yapi.interface_case from /www/backup/mongodb/yapi/interface_case.metadata.json

2020-01-19T23:42:32.549+0800    finished restoring yapi.group (50 documents)

2020-01-19T23:42:32.549+0800    reading metadata for yapi.token from /www/backup/mongodb/yapi/token.metadata.json

2020-01-19T23:42:32.565+0800    finished restoring yapi.interface_col (16 documents)

2020-01-19T23:42:32.565+0800    reading metadata for yapi.follow from /www/backup/mongodb/yapi/follow.metadata.json

2020-01-19T23:42:34.635+0800    restoring yapi.interface_case from /www/backup/mongodb/yapi/interface_case.bson

2020-01-19T23:42:35.226+0800    [##########..............]             yapi.log  6.18MB/14.4MB   (43.1%)

2020-01-19T23:42:35.226+0800    [########################]  yapi.interface_case    1008B/1008B  (100.0%)

2020-01-19T23:42:35.226+0800

2020-01-19T23:42:35.772+0800    restoring yapi.token from /www/backup/mongodb/yapi/token.bson

2020-01-19T23:42:35.845+0800    restoring yapi.follow from /www/backup/mongodb/yapi/follow.bson

2020-01-19T23:42:35.847+0800    restoring indexes for collection yapi.token from metadata

2020-01-19T23:42:35.848+0800    restoring indexes for collection yapi.follow from metadata

2020-01-19T23:42:35.848+0800    [########################]  yapi.interface_case  1008B/1008B  (100.0%)

2020-01-19T23:42:35.848+0800    restoring indexes for collection yapi.interface_case from metadata

2020-01-19T23:42:35.931+0800    finished restoring yapi.interface_case (2 documents)

2020-01-19T23:42:35.931+0800    reading metadata for yapi.adv_mock from /www/backup/mongodb/yapi/adv_mock.metadata.json

2020-01-19T23:42:35.931+0800    restoring yapi.adv_mock from /www/backup/mongodb/yapi/adv_mock.bson

2020-01-19T23:42:35.934+0800    restoring indexes for collection yapi.adv_mock from metadata

2020-01-19T23:42:35.944+0800    finished restoring yapi.token (14 documents)

2020-01-19T23:42:35.944+0800    reading metadata for yapi.adv_mock_case from /www/backup/mongodb/yapi/adv_mock_case.metadata.json

2020-01-19T23:42:35.945+0800    finished restoring yapi.adv_mock (0 documents)

2020-01-19T23:42:35.945+0800    reading metadata for yapi.wiki from /www/backup/mongodb/yapi/wiki.metadata.json

2020-01-19T23:42:35.945+0800    restoring yapi.adv_mock_case from /www/backup/mongodb/yapi/adv_mock_case.bson

2020-01-19T23:42:35.946+0800    restoring yapi.wiki from /www/backup/mongodb/yapi/wiki.bson

2020-01-19T23:42:35.947+0800    restoring indexes for collection yapi.adv_mock_case from metadata

2020-01-19T23:42:35.950+0800    restoring indexes for collection yapi.wiki from metadata

2020-01-19T23:42:35.968+0800    finished restoring yapi.adv_mock_case (0 documents)

2020-01-19T23:42:35.968+0800    finished restoring yapi.wiki (0 documents)

2020-01-19T23:42:35.968+0800    finished restoring yapi.follow (2 documents)

2020-01-19T23:42:36.044+0800    [########################]  yapi.log  14.4MB/14.4MB  (100.0%)

2020-01-19T23:42:36.044+0800    restoring indexes for collection yapi.log from metadata

2020-01-19T23:42:36.160+0800    finished restoring yapi.log (4148 documents)

2020-01-19T23:42:36.163+0800    done

[root@iZbp187tgql748sa0udwgrZ server]# 

启动yapi,http://apis.cdjsw.cn/访问正常。打开数据正常

文章来源:久思微软件开发运维部

头条文章
1 2020年成都久思微信息技术有限公司年会通知及相关软件开发项目安排
值此新春佳节来临之际,为感谢软件开发员工一年来的信任、辛勤工作,同时继续增进团队之间沟通和协作能力,能再接再厉再创辉煌,实现2020年公司软件开发年度目标,我司将举行“加强协作、稳进突破”为主题的年会活动
2 成都久思微信息技术有限公司2020年春节放假通知及软件开发相关安排
根据国务院办公厅国庆放假通知精神,并结合成都久思微信息技术有限公司及定制软件开发项目实际情况,经研究决定,公司决定2020年春节放假安排如下:
3 成都久思微信息技术有限公司2019年国庆放假通知
根据国务院办公厅国庆放假通知精神,并结和成都久思微信息技术有限公司及定制软件开发项目实际情况,经研究决定,公司决定2019年十一国庆节放假安排如下
4 成都企业级软件开发服务商:久思微乔迁新址再起新征程
成都久思微信息技术有限公司,成立于2014年4月10日,我们不忘初心,努力为客户带去更好的软件开发服务。每一个软件开发项目,久思微即以深耕的姿态从客户的发展和疼点的去分析软件开发需求、挖掘并理解客户的每一个疼点和细节,力求广大客户营造一个更加良好的开发体验。
5 成都定制软件开发服务公司:2019年51劳动节放假通知
 2019年5月1日-2019年5月4日——劳动节为国家法定假日。为便于各位同事及早合理地安排节假日软件开发或小程序定制开发及其已上线运维等有关工作,现将放假调休日期具体安排通知如下