Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Restore verifyonly on the last backup


Restore verifyonly on the last backup

Author
Message
OracleBoy
OracleBoy
SSC Rookie
SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)

Group: General Forum Members
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 Blush
(get the path of last full backup and use the command restore verifyonly from disk = <backup>
OracleBoy
OracleBoy
SSC Rookie
SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)

Group: General Forum Members
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
GilaMonster
GilaMonster
SSC-Forever
SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)

Group: General Forum Members
Points: 47243 Visits: 44377
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, MVP, M.Sc (Comp Sci)
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


OracleBoy
OracleBoy
SSC Rookie
SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)

Group: General Forum Members
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)
GilaMonster
GilaMonster
SSC-Forever
SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)

Group: General Forum Members
Points: 47243 Visits: 44377
Restore it.


Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
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


Michael Valentine Jones
Michael Valentine Jones
Hall of Fame
Hall of Fame (3.3K reputation)Hall of Fame (3.3K reputation)Hall of Fame (3.3K reputation)Hall of Fame (3.3K reputation)Hall of Fame (3.3K reputation)Hall of Fame (3.3K reputation)Hall of Fame (3.3K reputation)Hall of Fame (3.3K reputation)

Group: General Forum Members
Points: 3254 Visits: 11771
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.
zedshu
zedshu
Forum Newbie
Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: General Forum Members
Points: 3 Visits: 19
:-)v
zedshu
zedshu
Forum Newbie
Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: General Forum Members
Points: 3 Visits: 19
ag
zedshu
zedshu
Forum Newbie
Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: General Forum Members
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
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search