Restore data to the same bucket does not work

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:

  1. Prepare bucket with data (let’s call it ‘test-bucket’) and primary index. This is the only bucket in the cluster.
  2. Create backup using /opt/couchbase/bin/cbbackup http://host:8091 /backup_folder -u username -p password -b test-bucket command.
  3. Remove all the data from bucket by performing N1QL query ‘DELETE FROM test-bucket’.
  4. Run restore command /opt/couchbase/bin/cbrestore /backup_folder http://host:8091 -u username -p password --bucket-destination=test-bucket.
  5. Check the data in test-bucket.

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?

1 Like

Hi @dmytro.liashko,

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:

  1. Use flush instead of N1QL DML statement to delete all the documents
  2. Delete and recreate the bucket before doing the restore, no need to run the N1QL DML at all.
  3. Execute cbrestore with conflict_resolve=0 options, the documentation link above has an example of that option.

I hope that helps.

Hello.
Faced the same problem and still have not found a solution