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.
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.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.Use the
xdmp:database-restore
function with$journal-archiving
set tofn:true()
and$restoreToTime
set to the restore timestamp to restore the database.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 is2011-09-13T10:50:21.201832-07:00
, yourxdmp: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")))
Use
admin:database-set-merge-timestamp
function to set the merge timestamp back to the value you saved in Step 1.