Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I retrieve all revisions of a deleted document?

Tags:

couchdb

I know I can retrieve all revisions of an "available" document, but can I retrieve the last "available" version of a deleted document? I do not know the revision id prior to the delete. This is the command I am currently running...it returns {"error":"not_found","reason":"deleted"}.

curl -X GET http://localhost:5984/test_database/a213ccad?revs_info=true

like image 654
DanL Avatar asked Mar 25 '11 15:03

DanL


People also ask

How do I restore previous versions?

Right-click the file or folder, and then select Restore previous versions. You'll see a list of available previous versions of the file or folder. The list will include files saved on a backup (if you're using Windows Backup to back up your files) as well as restore points, if both types are available.

Can deleted documents be retrieved?

Yes, files can be recovered after being deleted. The level of difficulty depends on how long ago the file was deleted, however, and you may need to use specialized tools if trying to recover data that has been corrupted.

How do I retrieve accidentally erased?

To Restore That Important Missing File or Folder: Type Restore files in the search box on the taskbar, and then select Restore your files with File History. Look for the file you need, then use the arrows to see all its versions. When you find the version you want, select Restore to save it in its original location.

Can the deleted files be restored in the computer comment?

Here are the steps to restore a file or folder that was deleted or renamed (if the System Restore is enabled in advance): Double click on This PC icon on the desktop or press Windows + E to open File Explorer. Find the folder that contains the lost file or folder. Right click on it and select Restore previous versions.


2 Answers

I've got this problem, trying to recover deleted document, here is my solution:

0) until you run a compaction, get deleted history, e.g.:

curl http://example.iriscouch.com/test/_changes

1) you'll see deleted documents with $id and $rev, put empty document as new version, e.g.:

curl -X PUT http://example.iriscouch.com/test/$id?rev=$rev -H "Content-Type: application/json" -d {}

2) now you can get all revisions info, e.g:

curl http://example.iriscouch.com/test/$id?revs_info=true

See also Retrieve just deleted document

like image 174
avalez Avatar answered Sep 30 '22 04:09

avalez


Besides _changes, another good way to do this is to use keys with _all_docs:

GET $MYDB/_all_docs?keys=["foo"] ->

{
    "offset": 0,
    "rows": [
        {
            "id": "foo",
            "key": "foo",
            "value": {
                "deleted": true,
                "rev": "2-eec205a9d413992850a6e32678485900"
            }
        }
    ],
    "total_rows": 0
}

Note that it has to be keys; key will not work, because only keys returns info for deleted docs.

like image 20
nlawson Avatar answered Sep 30 '22 04:09

nlawson