Home > SQL Server Tips > Database Management and Administration > Best practices for SQL Server backup maintenance
SQL Server Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

DATABASE MANAGEMENT AND ADMINISTRATION

Best practices for SQL Server backup maintenance


Denny Cherry, Contributor
10.10.2007
Rating: -4.33- (out of 5)


Expert advice on database administration
Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


Part of your regular backup procedures should include removing old database backup history from the msdb database. That reduces the size of the msdb database and improves performance of the Enterprise Manager or Management Studio applications when you use them to restore.

This maintenance should be done via the sp_delete_backuphistory procedure in the msdb database. Microsoft provides it through the current CTP of Microsoft SQL Server 2008. The procedure accepts a single parameter called @oldest_date, which is the oldest date's backup information to keep. Differences between full backups, differential backups and transaction log backups are not shown. So, by running the command written below, you could end up with entries in the msdb database for transaction log backups and no corresponding full backup. That's fine because the backups don't have to be listed in the msdb tables in order to be restored to the SQL Server.

The maintenance command is as follows:

exec sp_delete_backuphistory '1/1/2005'

Another handy procedure is sp_delete_database_backuphistory, shown below. This removes all backup history for the database specified and should be used when databases leave production and are dropped from the server. For example:

Note: The examples are based on a DBA who works for Northwind Traders and has a database named Northwind.

colorexec sp_delete_database_backuphistory
'Northwind'

Backup database commands vs. maintenance plans

Although many database administrators have a preference, there is no actual difference with regard to backups between writing jobs that call the BACKUP DATABASE and BACKUP LOG commands and SQL Server maintenance plans. Both provide backups that you can restore using the RESTORE DATABASE command. Either method can be easily set up. Although maintenance plans provide a nice w...


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google



RELATED CONTENT
SQL Server Backup and Recovery
SQL Server Mailbag: Data restoration and DB property management
Achieving high availability and disaster recovery with SharePoint databases
How to 'do' SQL Server disaster recovery
The keys to database backup protection for SQL Server
Choosing a SQL Server disaster recovery solution
Licensing a standby server for SQL Server replication
Can I encrypt and restore a database backup in SQL Server 2005?
SQL Server errors, failures and other problems fixed from the trenches
Get SQL Server log shipping functionality without Enterprise Edition
SQL Server 2008 backup compression pros and cons
SQL Server Backup and Recovery Research

Microsoft SQL Server Performance Monitoring and Tuning
Using traces in SQL Server Profiler
SQL Server Mailbag: CALs, witnesses and unwanted changes
SQL Server Mailbag: Data restoration and DB property management
Working with IntelliSense in SQL Server 2008 Management Studio
SQL Server Mailbag: Stored procedures, triggers and SSRS reports
Troubleshooting Distributed Transaction Coordinator errors in SQL Server
Clearing the Windows page file and its effect on server performance
Optimizing SQL Server indexes –- even when they're not your indexes
Performance implications of transaction log autogrowth in SQL Server
The short course on how SQL Server really works

Database Management and Administration
Password cracking tools for SQL Server
Using traces in SQL Server Profiler
Meet compliance requirements with improved database security practices
Hardening the network and OS for SQL Server security
Securing the server and database in SQL Server
How SQL Server 2008 components impact SharePoint implementations
Troubleshooting Distributed Transaction Coordinator errors in SQL Server
Achieving high availability and disaster recovery with SharePoint databases
Clearing the Windows page file and its effect on server performance
Deploying a SQL Server virtual appliance for Microsoft Hyper-V

RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
rollback  (SearchSQLServer.com)

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary


izard to walk you through them, they do not allow for all the available options that BACKUP DATABASE and BACKUP LOG commands provide.

If you have worked on SQL Server 6.5, you'll remember having the ability to mirror the backup across multiple destinations to increase redundancy of the backup job. Microsoft restored this functionally in Microsoft SQL Server 2005 where it's done with the MIRROR TO clause. In using the MIRROR TO clause, the FORMAT switch must be included when creating the initial mirrored backup set. Like the regular destination, you can specify UNC paths to a network share on another server.

BACKUP DATABASE Northwind TO DISK='C:\
northwind.bak' MIRROR TO DISK='\\
SecondaryServer\c$\ northwind.bak'

When using the MIRROR TO clause, either DISK or a backup device can be specified. If any of the paths listed in the backup command are not available, the BACKUP DATABASE command will fail with an error message.

This tip was excerpted from Selecting the right SQL Server recovery model.

[IMAGE]

SQL Server database administrators must have a backup and recovery strategy in place and they must be certain it's the best plan for their SQL Server environment. Choosing the right recovery method is imperative for minimizing, or even preventing, data loss. In this edition of SQL Server INSIDER, expert Denny Cherry examines the backup and recovery strategies available and discusses how to make the correct decision for your SQL Server environment. Read this ezine from SearchSQLServer.com for tips on selecting the right backup method. Learn how to choose from the six main backup methods in use today:

• File-level backups
• Full backups only
• Full backups with differentials
• Full backups with transaction logs
• Full backups with differentials and transaction logs
• File group backups

Download this issue

ABOUT THE AUTHOR:   

Denny Cherry is a DBA and database architect managing one of the largest SQL Server installations in the world, supporting over 175 million users. Denny's primary areas of expertise are system architecture, performance tuning, replication and troubleshooting.
Copyright 2007 TechTarget


Rate this Tip
To rate tips, you must be a member of SearchSQLServer.com.
Register now to start rating these tips. Log in if you are already a member.




DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



SQL Server Development - .NET, C#, T-SQL, Visual Basic
HomeNewsTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersIT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2005 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts