Download presentation
Presentation is loading. Please wait.
Published byCatherine O’Neal’ Modified over 9 years ago
1
Backup and Restore
2
Backup Databases live in a fragile environment Machines can fail Disks can fail Programs can fail
3
Backup Backup creates an image of the database This image can be on: –Disk –Tape –CD/R –Other writeable media
4
What the Backup Does Remember that the database is made up of 1 or more files that are made up of 8K pages Backup reads these 8K pages and writes them where specified Backup works only at the 8K page level. It knows nothing about rows and columns
5
Types of Backup Full Backup Differential Backup Transaction Log Backup File and Filegroup Backup
6
Full Backup Backs up all pages in a database Normally a transaction log backup would also be done Restore would require full backup and trans log backup
7
Differential Backup Backs up only pages that have been changed since the last backup The page header has a flag indicating that the page is ‘dirty’ Normally a transaction log backup would be taken Restore would require last full backup, all differential backups and trans log backup
8
Transaction Log Backup Makes a copy of the the transaction log Does not copy any database pages Is needed when the transaction log becomes full
9
File Backups File backups are similar to database backup except they operate at the file level rather than the database level Can be full or differential Because they operate at the file level, several can run concurrently, speeding up backup time
10
Dump Device Also called Backup Device Before a backup can be run a dump device must be defined This is the location or device where the backup file will be written Is not required with v& and SQL Srvr 2K, but works
11
Create Dump Device sp_addumpdevice [ @devtype = ] 'device_type', [ @logicalname = ] 'logical_name', [ @physicalname = ] 'physical_name' [, { [ @cntrltype = ] controller_type | [ @devstatus = ] 'device_status' } ]
12
Examples EXEC sp_addumpdevice 'disk', 'mydiskdump', 'c:\dump\dump1.bak' EXEC sp_addumpdevice 'disk', 'networkdevice', '\\servername\sharename\path\filename.ext' EXEC sp_addumpdevice 'tape', 'tapedump1', '\\.\tape0'
13
Backup Command BACKUP DATABASE { database_name | @database_name_var } TO [,...n ] BACKUP DATABASE { database_name | @database_name_var } [,...n ] TO [,...n ] BACKUP LOG { database_name | @database_name_var } {TO [,...n ] }
14
Restore Restore takes the contents of a full backup and optionally differential backups and log backups and rebuilds the database Restore writes 8K pages with no knowledge of rows or columns
15
Restore Command RESTORE DATABASE { database_name | @database_name_var } [ FROM [,...n ] ]
16
Backup Considerations The backup is the final lifeline for a database A database should be backed up on a regular basis Each application may have a different meaning for regular Once per day, per week, or per month are not unusual periods
17
Backup Considerations Given the option you should not backup to the same physical disk that the database exists on (what happens if the disk goes out) You should have a backup separate from the server (tape?, networked drive?) You should have a backup that is off-site (professional offsite, your closet at home)
18
Backup Consideration Fight to make stand alone backups Don’t allow backups to be skipped Keep several backups A pattern of full backup and differential backups can be a successful strategy If using tape, get quality tapes and don’t overuse them (how much is the data worth?)
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.