Skip to main content

Administrating MarkLogic Server

Restoring to a Specific Timestamp

This procedure describes how to restore a database to a specific timestamp using the XQuery API.

Note

This same procedure can be done using the Admin Interfaces described in Setting Merge Policy, Admin Interface for Database Restore, and Rolling Back a Transaction.

  1. Use the admin:database-get-merge-timestamp function to get the current merge timestamp. Save this value so it can be reset after you have completed the rollback operation.

  2. Use the admin:database-set-merge-timestamp function to set the merge timestamp to any time before the restore timestamp. This will preserve fragments in merge after this timestamp until you have rolled back your forest data.

  3. Use the xdmp:database-restore function with $journal-archiving set to fn:true() and $restoreToTime set to the restore timestamp to restore the database.

  4. After the restore operation has completed, use the xdmp:forest-rollback function to roll back the forests to the restore timestamp. For example, if you are restoring the Documents database and the restore timestamp is 2011-09-13T10:50:21.201832-07:00, your xdmp:forest-rollback function call would be:

    xdmp:forest-rollback(
        xdmp:database-forests(xdmp:database("Documents")),
        xdmp:wallclock-to-timestamp(
          xs:dateTime("2011-09-13T10:50:21.201832-07:00")))
  5. Use admin:database-set-merge-timestamp function to set the merge timestamp back to the value you saved in Step 1.