Hi there.
I have Couchbase 6.0.0 Community Edition running on Ubuntu 19.04. Couchbase is organized to a cluster having 2 nodes. I try to test backup and restore procedure for a single bucket using following steps:
Prepare bucket with data (let’s call it ‘test-bucket’) and primary index. This is the only bucket in the cluster.
cbrestore command runs fine without any errors, but I am still getting empty test-bucket, so the data is not actually being restored. However, if I create another bucket, say, test-restore-bucket, and point --bucket-destination argument of cbrestore command to it, the data is being restored successfully to that bucket. Since it is not possible to rename buckets in Couchbase, restoring of data to a test-bucket is becoming a nightmare with those limitations. My question is - have someone else experienced the same problem and is it possible to restore the data without spare bucket being involved?
I have just tried following your steps, and I’m seeing the same thing. So it’s either:
Bug in cbbackup/cbrestore
We’re both doing something wrong
I find the first case unlikely, but nevertheless a possibility.
I find the second case more likely, but I’m not seeing anything in the documentation that says otherwise.
In either case, would you please create a ticket on https://issues.couchbase.com and basically just copy/paste your post? Please let me know what the ticket number is and I will do what I can to follow up?
This is working as design, cbrestore uses conflict resolution when putting the data back into the cluster, like how XDCR works. By doing the delete using N1QL, a tombstone of the document is create. The reversion of the document is bumped up assuming the default conflict resolution of the bucket is set. When cbrestore pushes the data back into the Server, it checks the reversion of the document and it takes the one that is greater, in this case that is the version it already has. For more information please see the cbrestore documentation
There are a few options:
Use flush instead of N1QL DML statement to delete all the documents
Delete and recreate the bucket before doing the restore, no need to run the N1QL DML at all.
Execute cbrestore with conflict_resolve=0 options, the documentation link above has an example of that option.