Create and Restore Database Snapshot

From Wiki-eostar.com
Jump to: navigation, search

The following is the proper way to create and restore from snapshot:

-- Create database snapshot
Create Database Snapshot_YourDatabaseName
ON
    (NAME = N'PrimaryFile', FILENAME = 'k:\DB\Primary_Snapshot_YourDatabaseName.ss')
    ,(NAME = N'BlobsFile', FILENAME = 'k:\DB\Blobs_Snapshot_YourDatabaseName.ss')
    ,(NAME = N'InventoryFile', FILENAME = 'k:\DB\Inventory_Snapshot_YourDatabaseName.ss')
    ,(NAME = N'OrdersFile', FILENAME = 'k:\DB\Orders_Snapshot_YourDatabaseName.ss')
AS SNAPSHOT OF YourDatabaseName
-- Revert original back to snapshot
RESTORE DATABASE YourDatabaseName
FROM DATABASE_SNAPSHOT = 'Snapshot_YourDatabaseName'