Couchbase Export few Documents

Requirement : Export few documents from one server of couchbase to another server. Basically bucket which has 1000 documents in Development Environment and take the selected document using a N1QL query (say the result to be 300 documents). Transfer these 300 documents to the UAT environment.
Is it possible?

Tried with couchbase Backup tool and it worked for single document. But how to append multiple documents? Or is it possible to give the n1ql query in the exporting options?

may be you can use curl() function (after CB 4.6.0) to get data from N1QL REST Query to insert into your server.

thanks @atom_yang.

Hi @Arunachalam,
The CURL() function in N1QL can surely help here, but that is coming in CB5.0. You can try it with developer builds available

Following blogs provide more details, and you can use it with INSERT-SELECT

If you are using 4.6, you can try the new import/export tool:


Thanks. I am getting the below error while inserting into the bucket.

insert into test(key k, value _v)
select meta().id _k, _v from test_1_v where id=“00001430-393”

Error is ,
“errors”: [
“code”: 5070,
“msg”: “Cannot INSERT non-string key Missing field or index k. of type value.missingValue.”.

How to resolve this? What mistake am i making? I am using 4.6.

try this

insert into test(key k, value _v)
select meta().id k, test1_v AS _v from test1_v where id="00001430-393"

Thanks. It worked. I will wait for Release 5 for using Curl command to transfer specific data from one server to another

Hi I have one document which was already existed in Couchbase DB. In the bucket the “ID ==abc”. And I want to generate same document, but ID should be “abc1”. I don’t understand how to use INSERT SELECT query. Can you please explain.

Use INSERT INTO SELECT statement. Example 8, 13-15 at