Restoring Based on Sample Documents
You may want to use the state of some sample documents to determine the time at which to restore the database.
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.
To restore to the state of sample documents using the XQuery API, follow these steps:
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 backup was taken. 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 totrue
and$restoreToTime
set to null( )
to restore the database to the latest timestamp.After the restore operation has completed, use point-in-time queries described in the Point-In-Time Queries in the Application Developer’s Guide to determine the time at which the sample documents last looked correct.
Use the
xdmp:forest-rollback
function to roll back the forests to the timestamp used for the successful point-in-time queries. For example, if you are restoring the Documents database and the documents at the timestamp2011-09-13T10:57:25.201832-07:00
look correct, 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.