Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Restore verifyonly on the last backup Expand / Collapse
Author
Message
Posted Thursday, March 28, 2013 6:17 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Thursday, July 25, 2013 1:48 PM
Points: 25, Visits: 74
Hi ,
Somebody can Help me :
I want a script to use 'restore verifyonly' command on the last full backup of my database
(get the path of last full backup and use the command restore verifyonly from disk = <backup>
Post #1436428
Posted Thursday, March 28, 2013 7:25 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Thursday, July 25, 2013 1:48 PM
Points: 25, Visits: 74
I don't know if it's the best way (but its work) :

DECLARE @backup nvarchar(90);
SELECT TOP 1 @backup = physical_device_name
FROM msdb.dbo.backupset b JOIN msdb.dbo.backupmediafamily m
ON b.media_set_id = m.media_set_id
WHERE database_name = 'dbsqware_mssql'
ORDER BY backup_finish_date DESC

RESTORE VERIFYONLY FROM disk= @backup
Post #1436456
Posted Thursday, March 28, 2013 8:51 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 5:25 AM
Points: 43,024, Visits: 36,185
Just a quick comment on the process, not the query...

Unless you've taken the full backup WITH CHECKSUM, the verifyonly verifies very little of the backup and can easily verify as valid a backup that won't restore. If you're going to depend on RESTORE VERIFYONLY, you need to ensure that all the backups are taken WITH CHECKSUM, even then it's not 100% certain.



Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #1436522
Posted Thursday, March 28, 2013 8:59 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Thursday, July 25, 2013 1:48 PM
Points: 25, Visits: 74
thank for your comment.
So there is not a way to verify that it(restore) works (backup with checksum or not)
Post #1436538
Posted Thursday, March 28, 2013 9:08 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 5:25 AM
Points: 43,024, Visits: 36,185
Restore it.


Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #1436545
Posted Thursday, March 28, 2013 9:42 AM
Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Today @ 12:39 AM
Points: 3,136, Visits: 11,494
GilaMonster (3/28/2013)
Just a quick comment on the process, not the query...

Unless you've taken the full backup WITH CHECKSUM, the verifyonly verifies very little of the backup and can easily verify as valid a backup that won't restore. If you're going to depend on RESTORE VERIFYONLY, you need to ensure that all the backups are taken WITH CHECKSUM, even then it's not 100% certain.


If you are using a Maintenance Plan, there is no option to set the WITH CHECKSUM option on for backups.

SQL Server Books Online (SQL Server 2008 R2) says the following under the BACKUP topic:
http://msdn.microsoft.com/en-us/library/ms186865(v=sql.105).aspx
"...
CHECKSUM
Enables backup checksums, so that BACKUP can do the following:
1. Prior to writing a page to the backup media, BACKUP verifies the page (page checksum or torn page), if this information is present on the page.
2. Regardless of whether page checksums are present, BACKUP generates a separate backup checksum for the backup streams. Restore operations can optionally use the backup checksum to validate that the backup is not corrupted. The backup checksum is stored on the backup media, not on the database pages. The backup checksum can optionally be used at restore time,

Using backup checksums may affect workload and backup throughput.

This is the default behavior for a compressed backup.
..."


However, when I run RESTORE HEADERONLY for a compressed backup made with a maintenance plan, the HasBackupChecksums column has a value of 0, which indicates the backup does not have checksums. I guess the Maintenance Plan is explicitly setting the NO_CHECKSUM option. Or Books Online is wrong.



UPDATE:
I just looked at a compressed backup that I was made with an explicit backup command, and the RESTORE HEADERONLY HasBackupChecksums column had a value of 0.

When I added the CHECKSUM option to the backup command, the RESTORE HEADERONLY HasBackupChecksums column had a value of 1.

It appears that SQL Server 2008 R2 Books Online is incorrect about CHECKSUM being the default for compressed backups.



Post #1436564
Posted Wednesday, February 26, 2014 5:41 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Wednesday, February 26, 2014 6:10 AM
Points: 3, Visits: 19
v
Post #1545342
Posted Wednesday, February 26, 2014 6:04 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Wednesday, February 26, 2014 6:10 AM
Points: 3, Visits: 19
ag
Post #1545356
Posted Wednesday, February 26, 2014 6:12 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Wednesday, February 26, 2014 6:10 AM
Points: 3, Visits: 19
What's the correct tsql syntax [SQL2008 r2] for RESTORE VERIFYONLY ...WITH CHECKSUM ?

I successfully backed up the follow DB WITH CHECKSUM and I believe I've followed the syntax for this correctly, but I'm not having any luck. If my syntax is wrong i'll gladly accept a knock on the noggin for the correct syntax. Or maybe my syntax is OK and the books online doco is wrong?

Here's my attempt WITH CHECKSUM:

RESTORE VERIFYONLY
FROM
DISK = 'Z:\foo\bar.bak'
WITH
CHECKSUM
,STATS = 2
RESTORE VERIFYONLY FAILED -- [<--from my print stmt]
@returnCode = 0 -- value of @@ERROR
@errorNum = 3013 -- value of ERROR_NUMBER()
@errorMsg = VERIFY DATABASE is terminating abnormally. -- value of ERROR_MESSAGE()
RETURN @returnCode = 3013.

Here's the other 'without' CHECKSUM:

RESTORE VERIFYONLY
FROM
DISK = 'Z:\foo\bar.bak'
WITH
--CHECKSUM
STATS = 2
18 percent processed.
37 percent processed.
55 percent processed.
74 percent processed.
92 percent processed.
100 percent processed.
The backup set on file 1 is valid.
RESTORE VERIFYONLY SUCCESSFUL. CONTINUING DB [bar] RESTORE. -- [<--from my print stmt]
@returnCode = 0 -- related postconditions
@errorNum = 0
@errorMsg = ''

Did it do a checksum validation w/o the 'WITH CHECKSUM' supplied? Or did it do this validation w/o the checksum validation? I tend to believe the answers are no, and yes, respectively. It would be nice if someone could confirm or refute this for me too.

thx
Post #1545360
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse