IBM Support

How do you restore a deleted document?

Question & Answer


Question

How do you restore a deleted document?

Answer

Answer

After a document is deleted, it can be restored if compaction has not take place. You can complete the following steps to determine whether if the document can be restored:

  1. Get the revision history using the following command:
    curl -u [username] ';https://[username].cloudant.com/[database]/[docID]?revs=true&open_revs=all';
    You will get a list of historical revisions.

  2. Get the previous revision using the following command:
    curl -u [username] ';https://[username].cloudant.com/[database]/[docID]?rev=[X-XXXXXXXXXXXXXXX]';
If compaction has occurred, there will not be any content left and it will show the following message:
{"error":"not_found","reason":"missing"}
If you can see content, compaction has not occurred. You can then restore the revision using the following steps:
  1. Retrieve the content and save it to a file using the following command:
    curl -u [username] ';https://[username].cloudant.com/[database]/[docID]?rev=[X-XXXXXXXXXXXXXXX]'; > xxx.json

  2. Post/PUT the content into a new document or an existing document. For more information, see the following documents:

[{"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Product":{"code":"SSCL17","label":"IBM Cloudant for IBM Cloud"},"Component":"","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"All Versions","Edition":"","Line of Business":{"code":"LOB21","label":"Public Cloud Platform"}}]

Document Information

Modified date:
01 August 2019

UID

ibm1KB0011069