Verify SQL Server Database Backup

Posted on : 04-01-2012 | By : Devi Prasad | In : DatabaseBackup, SQL Errors, SQLServerPedia Syndication

Share:

2


Today I wanted to share on this blog a simple but yet very powerfull SQL Server command RESTORE VERIFYONLY.

Syntax:
[sql]
RESTORE VERIFYONLY FROM DISK = ‘<<location of database backup>>’
[/sql]

This command can be used to check weather your database backup is corrupted.

In order to explain this, I have taken backup of one of my database.
I also made another copy of database backup and I intentionally corrupted it.

DatabaseBackup.BAK is the perfect database backup.
DatabaseBackupCorrupted.BAK is the corrupted database backup.

So First I issued RESTORE VERIFYONLY command on the perferct database backup.
Following is the Query:
[sql]
RESTORE VERIFYONLY FROM DISK = ‘C:\DatabaseBackups\DatabaseBackup.BAK’
[/sql]

Output:
The backup set on file 1 is valid.

There were no errors and this made me confirm that the database backup is perfect.

Now I issued the same command on the corrupted database backup.
[sql]
RESTORE VERIFYONLY FROM DISK = ‘C:\DatabaseBackups\DatabaseBackupCorrupted.BAK’
[/sql]

As we expect the command errored out with the following error.

Output:

Msg 3242, Level 16, State 2, Line 1
The file on device ‘C:\DatabaseBackups\DatabaseBackupCorrupted.BAK’ is not a valid Microsoft Tape Format backup set.
Msg 3013, Level 16, State 1, Line 1
VERIFY DATABASE is terminating abnormally.

There this error output confirms me that the database backup is corrupted.

When ever restoration of a database backup is failing we can use the RESTORE VERIFYONLY command on the back up set and verify it.

Note:
You get the error Operating system error 2(The system cannot find the file specified) when the file cannot be found on the file system. In order to fix it give the correct file name and file path.

Msg 3201, Level 16, State 2, Line 1 Cannot open backup device
‘C:\DatabaseBackups\DatabaseBackupCorrupted1.BAK’. Operating system error 2(The system cannot find the file specified.).
Msg 3013, Level 16, State 1, Line 1
VERIFY DATABASE is terminating abnormally.

I got the above error when I issued the following command:
[sql]
RESTORE VERIFYONLY FROM DISK = ‘C:\DatabaseBackup.BAK’
[/sql]
As the file C:\DatabaseBackup.BAK does not exists.

Hope this posts helps!!!

Related post:
The media family on device is incorrectly formed. SQL Server cannot process this media family Error: 3241




References : Devi Prasad (sqlserverlearner.com)

Need Help On SQL Server?

Cannot Find Solution to your problem (or) If you are looking for some help on SQL Server. Dont worry Click Here to Post your question and solve your issue.


Do you like my blog?

If you liked reading this blog, please help spread the word by sharing this blog with your friends.




Comments (2)

[…] Backup file is corrupted. The following post helps you verify your database backup: Verify SQL Server Database Backup […]

[…] posts: Verify SQL Server Database Backup restore higher version database backup on lower version sql server – restore problem The media […]

Write a comment



Tags: , , , , , , , , , , , , , ,