Presentation is loading. Please wait.

Presentation is loading. Please wait.

The Nitty-Gritty of Database Backups

Similar presentations


Presentation on theme: "The Nitty-Gritty of Database Backups"— Presentation transcript:

1 The Nitty-Gritty of Database Backups
by Brandie Tarvin MCITPDBA, MCTS, MCDBA, MCSA Introduce self. Remind all this is a basics course. Details can be found in Books Online (your new best friend) or on SQLServerCentral.com or other sources.

2 Backup, Backup. Who’s got the backup?
Which of these files are backup files? Which ones are not and what are they?

3

4 Keywords to Live By Recovery Model (aka Recovery Mode) Full
Bulk-Logged Simple Backup Types Differential File & Filegroup Transaction Log Partial (new to 2005 and on) Copy Only (new to 2005 and on) Compression (new to 2008)

5 The Database Recovery Model
Full Full, Full Differential, Transaction Log Bulk-Logged Simple Full, Differential (restricted) File / FileGroup, Partial, Copy Only & Compressed backups can be done regardless of Recovery Model Don’t confuse Full Recovery Mode with a Full Database Backup or Full Database Restore. Restricted on Simple Mode Differential means that it backs up the extents as opposed to the actual data (per BOL) Full recovery fully logs every transaction. Bulk-Logged fully logs all transactions except minimally logged (BCP, Bulk Insert, OpenRowSet, etc). Minimally logged means it logs the extents allocated, not the actual data. Simple uses the transaction log to keep uncommitted transactions in, but you can’t backup the transaction log because it truncates the transactions as soon as they are recovered. Only Full Recovery Mode allows Point in Time restores. Bulk-Logged can be restored to most recent transaction log and Simple can only be restored to the last non-transaction log backup. Full recovery mode keeps all committed transactions & rolls back all in-process ones. Logs can be backed up while full or differential backups are running. Logs all operations. Can do Point in Time restores with Full. Bulk-Logged recovery mode does not log all transactions. It minimally logs for bulk loads (BCP, Bulk Insert, OpenRowSet, etc.) & index creation operations while fully logging other transactions. Handy for when doing a datawarehouse or other heavy write DB. What minimal logging means is that only the amount of space used for a load (the extent allocation) will be logged. The actual data changes will not be tracked. Can't do Point in Time, but can recover to last transaction log. Simple recovery mode still uses the transaction log! All recovery modes do. However, in Simple mode, you can't recover uncommitted transactions because you can't back up the log. Nor can you shrink it, make changes to it or restore to a Point In Time. Can only recover to last non-log backup.

6 The Backup Types Full (aka Complete) Backups Differential Backups
File / Filegroup Backups Partial Backups Copy Only Backups Compressed Backups (must be enabled) **Incremental Backups were last available with SQL No longer used in SQL Server Incremental backups backed up changes since the last Incremental backup. Which means you needed the last Full backup and every single Incremental backup since then in order to restore your database. Microsoft has quietly gotten rid of them for reasons unknown, but it’s possible few people used them. They had fast fast fast backups but super slow recovery time because of the way they were designed.

7 Full Backups Backs up the entire database file (.mdf) at the time of backup – think snapshot Unless using 3rd party tool with compression or SQL 2k8, backup file will be same size as DB at time of backup Takes most time for backing up

8 Differential Backups With Full Recovery Mode, will backup only changes since last Full Backup File smaller than database & last full backup file (usually) Good for use with VLDBs Faster backup time than Full Backup Recovery can take longer than Full Backup because both Full Backup & most recent Differential are needed (not all differentials)

9 File / Filegroup Backups
Transaction Backups MUST be used, which means DB needs Full or Bulk-Logged Recovery Mode Full set of file backups & covering Transaction Log backups must be kept Backup time can be short. So can Restore time Cannot use Point in Time Restores. A file is restored as “all or nothing” Can only be restored to the database to which they belong (not a copy on another server) See Books Online for more details

10 Transaction Log Backups
Truncates (removes) committed transactions out of the log making room for new ones Keeps your transaction log from growing at a disproportionate rate Allows Point in Time restores in conjunction with Full backups Can be read with 3rd party tools to search for transactions that deleted or modified or inserted data (depending on recovery mode)

11 Partial Backups New to SQL 2005 A lot like file / filegroup backups
Only backs up read / write filegroups and primary filegroup Backup time is really super quick Can restore on the partial also without having to restore to a total restore Can do FULL Partial backup (everything) or Differential Partial backup (changes only) Good for Data Warehouse Backup Plans

12 Copy Only Backups Allows for making a “photocopy” of your database without disrupting the history of current backup process Good for sending backups to other non-Production servers (Test / QC / Dev / Report) or other “special purposes” Cannot be used as a “base” backup for a restore Does not truncate Transaction Log Explain concept of backup & log chains if there is time

13 Important Schtuff to Remember
Always start from a Full Backup Differentials mostly useful for DWs, VLDBs, when time constraints matter Always backup Transaction Log unless using Simple Recovery Mode File / Filegroup backups can be useful, but restores can be complicated Keep as many days / weeks as you need to feel comfortable with Keep more than 1 day’s worth of backups, somewhere Using Windows Backup Software on Database Files is NO SUBSTITUTE! Test your backups regularly to make sure they restore correctly

14 References SQL Server Books Online (subject “database backups [SQL Server]”) Google – search on terms in presentation with “SQL Server” in front Brandie Tarvin ( – coming soon)


Download ppt "The Nitty-Gritty of Database Backups"

Similar presentations


Ads by Google