Getting Started with Adobe After Effects - Part 6: Motion Blur


Upload Image Close it
Select File

A place to share commonly used scripts for SQL Server Database Administrators.

Moderators

SQL Server DBA Scripts

A simple script to perform basic databaes backup file verification

Jul 14 2012 12:00AM by Nakul Vachhrajani   

SQL Server provides a way to verify a database backup using the T-SQL command - RESTORE. This verification ensures that all backup sets are readable, checksum verification (if backup is checksum protected) and checking for sufficient space on the destination drives.

The following script uses the VERIFYONLY option of the RESTORE T-SQL command, which performs the following checks (according to Books On Line):

  • That the backup set is complete and all volumes are readable
  • Some header fields of database pages, such as the page ID (as if it were about to write the data)
  • Checksum (if present on the media)
  • Checking for sufficient space on destination devices

Please NOTE: VERIFYONLY is your first line of defence. It does not perform detailed verification (like logical corruption), which needs to be performed separately.

USE MASTER
-- Add a new backup device
-- Ensure that the SQL Server can read from the physical location where the backup is placed
--                    TYPE      NAME    	   PHYSICAL LOCATION
EXEC SP_ADDUMPDEVICE 'disk','networkdrive','\\VPCW2K8\Database Backup\Test.bak'

-- Execute the Restore operation in VERIFY ONLY mode
-- Provide the actual paths where you plan to restore the database.
-- This is because VERIFYONLY also checks for available space
RESTORE
VERIFYONLY
FROM  networkdrive
WITH
MOVE N'TESTDB_DATA'    TO N'E:\TestDB\TestDB_Data.mdf',  
MOVE N'TESTDB_INDEXES' TO N'E:\TestDB\TestDB_Idx.mdf',  
MOVE N'TESTDB_LOG'     TO N'E:\TestDB\TestDB_LOG.ldf'

-- DROP THE DEVICE
--                   Name         , Physical File (OPTIONAL - if present, the file is deleted)
EXEC SP_DROPDEVICE 'networkdrive'


Nakul Vachhrajani
4 · 33% · 10564
3
 
1
 
0
Failed
 
0
Lifesaver
 
 
0
Unwise



Submit

2  Comments  

  • What is the purpose of creating and dropping a backup device? Why not directly supply the UNC path to the backup file?

    commented on Jul 15 2012 6:56AM
    Marc Jellinek
    97 · 2% · 545
  • @Marc: Thanks for asking.

    The way I implemented this was that a backup device was created once. Backups were then scheduled to this device via a scheduled job/task. Instead of passing the same UNC path again and again to the scheduled job, I thought it to be more convenient to create a backup device and use that instead.

    If the backup is a one-time thing, one can definitely use the UNC path directly.

    I tried to compress this into one script.

    commented on Jul 15 2012 12:18PM
    Nakul Vachhrajani
    4 · 33% · 10564

Your Comment


Sign Up or Login to post a comment.

"A simple script to perform basic databaes backup file verification" rated 5 out of 5 by 3 readers
A simple script to perform basic databaes backup file verification , 5.0 out of 5 based on 3 ratings
    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]