{"id":105,"date":"2012-01-04T07:07:44","date_gmt":"2012-01-04T07:07:44","guid":{"rendered":"https:\/\/sqlserverlearner.azurewebsites.net\/2012\/01\/04\/verify-sql-server-database-backup\/"},"modified":"2012-01-04T07:07:44","modified_gmt":"2012-01-04T07:07:44","slug":"verify-sql-server-database-backup","status":"publish","type":"post","link":"https:\/\/sqlserverlearner.com\/2012\/01\/04\/verify-sql-server-database-backup\/","title":{"rendered":"Verify SQL Server Database Backup"},"content":{"rendered":"
Today I wanted to share on this blog a simple but yet very powerfull SQL Server command RESTORE VERIFYONLY<\/strong>.<\/p>\n Syntax:<\/strong> This command can be used to check weather your database backup is corrupted.<\/p>\n In order to explain this, I have taken backup of one of my database. DatabaseBackup.BAK is the perfect database backup. So First I issued RESTORE VERIFYONLY command on the perferct database backup. Output: There were no errors and this made me confirm that the database backup is perfect.<\/strong><\/p>\n Now I issued the same command on the corrupted database backup. As we expect the command errored out with the following error.<\/p>\n Output: There this error output confirms me that the database backup is corrupted.<\/strong><\/p>\n When ever restoration of a database backup is failing we can use the RESTORE VERIFYONLY command on the back up set and verify it.<\/p>\n Note:<\/strong>
\n[sql]
\nRESTORE VERIFYONLY FROM DISK = ‘<<location of database backup>>’
\n[\/sql]<\/p>\n
\nI also made another copy of database backup and I intentionally corrupted it.<\/p>\n
\nDatabaseBackupCorrupted.BAK is the corrupted database backup.<\/p>\n
\nFollowing is the Query:
\n[sql]
\nRESTORE VERIFYONLY FROM DISK = ‘C:DatabaseBackupsDatabaseBackup.BAK’
\n[\/sql]<\/p>\n
\nThe backup set on file 1 is valid.<\/em><\/p>\n
\n[sql]
\nRESTORE VERIFYONLY FROM DISK = ‘C:DatabaseBackupsDatabaseBackupCorrupted.BAK’
\n[\/sql]<\/p>\n
\n
\nMsg 3242, Level 16, State 2, Line 1
\nThe file on device ‘C:DatabaseBackupsDatabaseBackupCorrupted.BAK’ is not a valid Microsoft Tape Format backup set.
\nMsg 3013, Level 16, State 1, Line 1
\nVERIFY DATABASE is terminating abnormally.
\n<\/font><\/p>\n
\nYou get the error Operating system error 2(The system cannot find the file specified)<\/strong> when the file cannot be found on the file system. In order to fix it give the correct file name and file path.
\n
\nMsg 3201, Level 16, State 2, Line 1 Cannot open backup device
\n‘C:DatabaseBackupsDatabaseBackupCorrupted1.BAK’. Operating system error 2(The system cannot find the file specified.).
\nMsg 3013, Level 16, State 1, Line 1
\nVERIFY DATABASE is terminating abnormally.
\n<\/font><\/p>\n