CouchDB转储到文件并从文件加载 [英] CouchDB dump to file and load from file

查看:78
本文介绍了CouchDB转储到文件并从文件加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法在两台CouchDB服务器之间进行复制,因此我想从一台服务器转储到文件,然后从文件加载到另一台服务器.

我使用此语句转储,并且工作正常:

  curl -X GET http://localhost:5984/< DATABASE_NAME>/_all_docs?include_docs = true>FILE.txt 

但是当我使用此语句加载时:

  curl -d @ FILE.txt -H内容类型:应用程序/json" -X POST http://localhost:5984/< DATABASE_NAME>/_bulk_docs 

它失败了,像这样:

  curl:(6)无法解析主机:应用程序;找不到主机{错误":"bad_content_type",原因":内容类型必须为application/json"} 

有什么想法吗?

解决方案

如上所述,您应该使用"而不是" 作为的参数-H 选项

如果您是Linux或MacOSX用户,则可以使用 couchdb-dump 工具,该工具基本上可以在bash shell上运行

它将数据库转储到本地文件(ASCII文本文件)中,格式为 http://wiki.apache.org要求的格式/couchdb/HTTP_Bulk_Document_API

然后,您可以使用批量文件上传或软件包中包含的couchdb-dump恢复工具来恢复它.

这是该工具的链接: https://github.com/animamea/couchdb-dump

但是您还可以找到其他工具:

https://github.com/stockr-labs/couchdbdump

https://github.com/zebooka/couchdb-dump

I cannot replicate between two couchdb servers, so I would like to dump to file from one server and load from file into the other server.

I used this statement to dump and it worked fine:

curl -X GET http://localhost:5984/<DATABASE_NAME>/_all_docs?include_docs=true > FILE.txt

But when I used this statement to load:

curl -d @FILE.txt -H "Content-Type: application/json" -X POST http://localhost:5984/<DATABASE_NAME>/_bulk_docs

it failed like this:

curl: (6) Could not resolve host: application; Host not found {"error":"bad_content_type","reason":"Content-Type must be application/json"}

Any ideas?

解决方案

As said, you should use the " and not the " as argument of the -H option

If you are a Linux or MacOSX user you can use the couchdb-dump tool, which basically works on bash shell.

It dumps the database on a local file (ASCII text file), formatted as requested by http://wiki.apache.org/couchdb/HTTP_Bulk_Document_API

Then you can restore it with the bulk document upload or with the couchdb-dump restore tool included in the package.

This is the link to the tool: https://github.com/animamea/couchdb-dump

But you can find other tools also:

https://github.com/stockr-labs/couchdbdump

https://github.com/zebooka/couchdb-dump

这篇关于CouchDB转储到文件并从文件加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆