Thursday, May 31, 2012

Find if backup file is complete or not

Frequently we get back up files from our clients to resolve their issues. But sometimes by the time the backup file reaches us, it gets corrupted either while creating the back up or while compressing or while uploading to ftp site or while downloading from the ftp site.
When we try to restore such file, we may get different error messages.

One message that I got recently was: Specified cast is not valid. (SqlManagerUI)

One very good way to find out if the backup file is incomplete is to execute following command

RESTORE HEADERONLY FROM DISK = 'C:\TEST.BAK'

It will show something like the below message which implies that the backup is not complete:



Similarly if you want to see what will be the space requirement for the restored back file it terms of the mdf and ldf, you can execute following:

RESTORE FILELISTONLY FROM DISK = N'v:\MyBackup.bak'




1 comment: