Is there good way to backup and delete and backout the document from couchdb?

264 Views Asked by At

I have some couchdb document need to be removed, Is there good way/steps to backup and delete and backout those document from couchdb?

2

There are 2 best solutions below

0
natevw On

I've written a blog post about the three ways to delete a document from CouchDB which may be helpful. I'll summarize here:

  • saving a document with a _deleted:true field removes it from most views, but the final values of other document fields are still available. This deletion replicates.
  • using DELETE /{db}/{docid} ends up setting a _deleted:true field like above, but clears all other document fields instead of leaving them. (This deletion likewise replicates.)
  • using POST /{db}/_purge makes the local server forget a document ever existed (at least after compaction is done). This will NOT replicate.

My guess from your "backout those document from couchdb" is that you accidentally uploaded something that you want completely removed, in which case you might look into the _purge option. Otherwise your CouchDB library probably has a method for normally deleting documents just as easily as creating them.

0
MaX On

Using CouchDB 1.X you can just save *.couch files corresponding to your databases. Then later you'll be able to use these files to recover your data.

Using 2.X I have no idea how to do achieve that since each database is split in shards and the _dbs.couch seems to be needed to restore data. Then you can have a complete backup but not a single database backup. If someone knows how to do that I need the answer too :)