Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 SQL Server Administration (2008)
 Testing backups

Author  Topic 

chris_cs
Posting Yak Master

223 Posts

Posted - 2012-04-02 : 10:35:29
I was curious as to how people handle testing their database backups in terms of a test restore in large environments.

We don't have a proper procedure in place so I'm looking to create one. We restore a lot of our databases to UAT/DEV environments every now again but I don't want to assume these fairly infrequent restores means all backups are ok.

Ideally I'd like to automate the process but I'm not sure how feasible this is.

Would a test restore job on each server work? Or would I just have to schedule manual tests?

Thanks in advance

----------------------------
Junior DBA learning the ropes

X002548
Not Just a Number

15586 Posts

Posted - 2012-04-02 : 11:10:09
Every time I make a backup, as part of the procedure I do a restore to make sure the back up is ok

You can always make a backup and go to it, only to find that the backup is bad (I actually have never seen that happen, but the job of a dba is to be a pessimist)

I also create regression script to test out all of my sprocs. We use that also everytime we migrate code changes, but I guess you could use that as well

make this part of your back up plans



USE [master]
GO


-- Check to see that the DB is in Good Health

DBCC CHECKDB ('<dbname>')
GO

-- Back up DB to a local drive on the server, not across the network

BACKUP DATABASE [<dbname>]
TO DISK = N'<fp>\<servername>_<instancename>_<dbname>_D<yyyymmdd>_T<hhmiss>.BAK'
WITH NOFORMAT, INIT, NAME = N'<dbnaem> Full Database Backup', SKIP, NOREWIND, NOUNLOAD, STATS = 10
GO

-- Run This next block through the Verify

DECLARE @backupSetId int

SELECT @backupSetId = position
FROM msdb..backupset
WHERE database_name=N'<dbname>'
AND backup_set_id=(select max(backup_set_id) from msdb..backupset where database_name=N'<dbname>' )

IF @backupSetId is null
BEGIN
raiserror(N'Verify failed. Backup information for database ''<dbname>'' not found.', 16, 1)
END

RESTORE VERIFYONLY
FROM DISK = N'<fp>\<servername>_<instancename>_<dbname>_D<yyyymmdd>_T<hhmiss>.BAK'
WITH FILE = @backupSetId, NOUNLOAD, NOREWIND
GO

-- Run this to test the back up. Once the Backup Verify is restored, go check the verify database

-- Check for logical file names and locations

RESTORE FILELISTONLY
FROM DISK = N'<fp>\<servername>_<instancename>_<dbname>_D<yyyymmdd>_T<hhmiss>.BAK'
GO

-- Test the Backup

ALTER DATABASE <dbname>_VERIFY SET SINGLE_USER WITH ROLLBACK IMMEDIATE
GO

-- Restore Database to Verify

RESTORE DATABASE <dbname>_VERIFY
FROM DISK = N'<fp>\<servername>_<instancename>_<dbname>_D<yyyymmdd>_T<hhmiss>.BAK'
WITH MOVE '<dbname>' TO '<fp DBFile>\<dbname>\<dbname>_VERIFY.MDF'
, MOVE '<dbname>_LOG' TO '<fp DBFile>\<dbname>\<dbname>_VERIFY.LDF'
, REPLACE
GO

-- Put the database into Multi user and read write mode

ALTER DATABASE <dbname>_VERIFY SET READ_WRITE
ALTER DATABASE <dbname>_VERIFY SET MULTI_USER
GO

-- Check out the Verify DB to make sure it looks good.

USE [<dbname>_VERIFY]
GO




Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

chris_cs
Posting Yak Master

223 Posts

Posted - 2012-04-02 : 11:35:12
Thanks for the response Brett.

My initial thought was to create a separate job to the backup one but I guess it makes sense to have it all in one. I'm not sure this'll work on all our servers though. One has about 2000 databases so the job would run way too long!

I was also going to as if people include DBCC in their backup scripts and I can see you do. Is this the same across the whole of your production environment?

Would a full DBCC CHECKDB be necessary or could I use PHYSICALY_ONLY? I ask this from a time point of view.

----------------------------
Junior DBA learning the ropes
Go to Top of Page
   

- Advertisement -