We get the below error message when we try to restore from tape for large databases.
ERROR MESSAGE:
==============
TITLE: Microsoft SQL Server Management Studio
------------------------------
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
------------------------------
ADDITIONAL INFORMATION:
Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. (Microsoft SQL Server, Error: -2)
For help, click: <http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=09.00.3282&EvtSrc=MSSQLServer&EvtID=-2&LinkId=20476>
------------------------------
Cause
======
When we use the SQL Server Management Studio GUI to perform a restore of a large database, we encounter the following message:
Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
RESTORE HEADERONLY is terminating abnormally. (.Net SqlClient Data Provider)
These are the steps that take place in the background when the restore is performed in GUI,
Step 1: Enumerate the backup devices.
Step 2: Fetch details about the backup that we are trying to restore
Step 3: Fetch the backup header (This can take time depending on the size of the backup and backup media/device)
RESTOREHEADERONLYFROM Tape= ' \\.\tape0'WITH NOUNLOAD--- this tries to fetch the header information from the tape for a specified amount of time.
Step 4: Obtain the list of files present in the backup set/media.
RESTOREFILELISTONLYFROMTape= ' \\.\tape0' WITH NOUNLOAD, FILE=(file_number)
Step 5: Perform the actual restore operation.
RESTOREDATABASE [Database name] FROM DISK=Tape= ' \\.\tape0' WITH FILE=(file_number), NORECOVERY, NOUNLOAD, STATS=(percentage)
In GUI this fails for large databases due to the fact that certain operations like the below sequence have a built-in timeout of 20 seconds.
Right click on a database >> Tasks >> Restore >> Database >> From Device >> Click on button >> Backup Media = TAPE >> Add >> Select Backup tape >> OK >> OK.
The timeout will happen on the "Specify Backup" dialog.
This timeout is to prevent these dialog boxes from hanging forever when there is no tape present in the drive.
If you run the "RESTORE HEADERONLY" command from Tsql, you can see that it takes several minutes to complete which is much longer than the 20 second timeout for GUI.
To work around the issue, we can need to use T-SQL from Management Studio.
For the restore:
RESTOREDATABASE<Database name>
FROMTAPE='\\.\tape0'
WITH
NOREWIND,
NOUNLOAD,
STATS= 1
GO
FIX: A time-out occurs when you use SQL Server Management Studio to try to restore a large database from a backup on a tape in SQL Server 2008
http://support.microsoft.com/default.aspx?scid=kb;EN-US;967205
SE, Microsoft SQL Server
Reviewed by
Amit Banerjee, TL, Microsoft SQL Server