Restore Couchbase Database from .couch files

Hello Couchbase team,

I am using helm/kubernetes to deploy a couchbase cluster (operator v2.0.2).

Today I had an incident where I lost all nodes of the couchbase cluster, the only thing I could get was a snapshot from the PV in AWS. The cluster consists of 3 nodes (using the default helm chart config).

Looking inside those volumes, I come to understand that couchbase store the files in .couch files.

I found a tool called cbtransfer that can consume the couchstore files but I am hitting an error:

./cbtransfer couchstore-files:///mnt/cb_data/  http://localhost:8091 -u admin -p pwd -b XYZ -B XYZ
error: missing vbuckets in source_bucket: XYZ

Can anyone please help ?

Cheers.

Hello @Noteworthy ,

Sorry to hear that you ran into a problem. The command provided looks correct, the error message is saying that there is no *.couch.* files in the XYZ folder. It would be best to double check that the bucket name and path are correct (I suspect you have already done this).

To debug this could you share the output of ls -l /mnt/cb_data/ and /mnt/cb_data/XYZ please.

1 Like

Thanks a lot @pvarley for your reply.

Here is the output of the first command:
20G ./files
63M ./users
65M ./default

These are my 3 buckets, default is just the default one that comes with couchbase, files and users are what matters to me.

Here is the content of the second command: Couchbase .couch files - Pastebin.com

Because my cluster consist of 3 nodes: cb0, cb1 and cb2. The command I was running above was against the data/ folder of cb0.

I tried the same thing in cb2 and cb1 and it worked, however going to the UI the data seems to be a bit broken:

From cb1 and cb2, I got all of my data back, I am very happy about it, I just need to fix why couchbase thinks it is a binary document, coz it is not, it is a plain json.

I am using version 6.5.1.

Update: Well, finally I restored everything :slight_smile: with the help of couch_dbdump I was able to dump all .couche files to json and simply re-insert them.

Cheers.

Hi @Noteworthy I had a look into the issue. I appreciate you have found a workaround but just in case this happens again I can explain what happened and how to get around it.

The reason the documents are being transfered as binary is that the documents in the couchstore files where compressed. Due to a bug in that version of cbtransfer it incorrectly restores compressed documents as binary, you can get around it by using the -x uncompress=1 so the command would look like:

./cbtransfer couchstore-files:///mnt/cb_data/  http://localhost:8091 -u admin -p pwd -b XYZ -B XYZ -x uncompress=1

This bug will be fixed in 7.0.0 and 6.6.2.

2 Likes

I confirm it works ! Thanks a lot @Carlos_Gonzalez and @pvarley

1 Like

Glad you got this sorted, sorry I couldn’t help more at the time on Gitter.

1 Like