Restoring to a Specific Timestamp
- Last Updated: April 15, 2026
- 1 minute read
- MarkLogic Server
- Version 11.0
- Documentation
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-timestampfunction 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-timestampfunction 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-restorefunction with$journal-archivingset tofn:true()and$restoreToTimeset to the restore timestamp to restore the database. -
After the restore operation has completed, use the
xdmp:forest-rollbackfunction 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-rollbackfunction 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")))