Lesson 1: Planning a Backup Strategy
SQL Server Backup Types
Backup Type | Description |
Full | 모든 데이터 파일과 트랜잭션 로그의 일부분을 백업한다. |
Transaction log | 로그 파일에 기록된 데이터베이스 변화들을 백업한다. |
Tail-log | 로그의 활성부분(active portion)을 백업한다. |
Differential | The parts of the database that have changed since the last full database backup |
File/Filegroup | Specified files or filegroups |
Partial | The primary filegroup, every read/write filegroup, and any specified read-only filegroups |
Copy-only | The database or log (without affecting the backup sequence) |
What Are Recovery Models?
Recovery Model | Description |
Simple | Uses full or differential copies of the database. Truncates the transaction logs. |
Full | Includes both database backups and transaction log backups. |
Bulk-logged | Includes both database and transaction log backups, but uses less log space for some operations. |
What Is a Full Database Backup Strategy?
What Is a Database and Transaction Log Backup Strategy?
What Is a Differential Bakcup Strategy?
What Is a File of Filegroup Backup Strategy?
Considerations for Backup Operators
Lesson 2: Backing Up User Databases
Options for Ensuring Backup Integrity
Use the MIRROR TO option of the BACKUP statement
Use the CHECKSUM option of the BACKUP and RESTORE statements
Use the RESTORE VERIFYONLY statement to validate the backup
Lesson 3: Restoring User Databases
How the Restore Process Works
How to Restore a Database
Restore from a full or differential backup
Use RECOVERY or NORECOVERY to control recovery behavior
Use MOVE…TO option to change file locations
Use REPLACE option to replace an existing database
USE master
RESTORE DATABASE AdventureWorks
FROM AWBack
WITH NORECOVERY
RESTORE DATABASE AdventureWorks
FROM AWBackDiff
WITH RECOVERY
How to Restore a Transaction Log
Overview of Online Restore Operations
Database
+--------------------+
Primary filegroup | Primary |
online, database -------> Filegrup |
available | |
| |
| |
File unavailable, -------> Filegroup A |<------- Restoring file [백업장치(테이프,디스크)]
filegroup offline | |
| |
| |
All files available, -------> Filegroup B |
filegroup online | |
+--------------------+
How to Restore a Damaged Page
Identify ID of damaged page
Restore page from a full or differential backup
Use PAGE clause to specify pages to restore
Specify NORECOVERY
RESTORE DATABASE AdventureWorks
PAGE = '1:610'
FROM AWBack
WITH NORECOVERY
Restore transaction logs
Backup transaction log tail
Restore transaction log tail
How to Restore a File
Restore damaged file from a full or differential backup
Use FILE clause to specify file to restore
Specify NORECOVERY
RESTORE DATABASE AdventureWorks
FILE = AW2
FROM AWBack
WITH NORECOVERY
Backup transaction log tail
Specify COPY_ONLY
Restore transaction logs
Restore transaction log tail
How to Restore a Filegroup
Backup transaction log tail
Specify NORECOVERY
Restore filegroup from a full or differentail backup
Use FILEGROUP clause to specity filegroup to restore
Specify PARTIAL and NORECOVERY
RESTORE DATABASE AdventureWorks
FILEGROUP = 'DYNAMIC_DATA'
FROM AWBackDynamic
WITH PARTIAL, NORECOVERY
Restore transaction logs
Restore transaction log tail
Restore a database in stages based on filegroups
Each filegroup comes online as it is restored
Transactions involving filegroups not yet restored will hold locks until rollback can complete
Lesson 5: Recovering Data from Database Snapshots
What Is a Database Snapshot?
Read-only, consistent view of a database at a specified point in time
Useful as test or development database, or for reporting
Must exist on same server as source database
How Database Snapshots Work
Source DB Snapshot DB
+--------+ +--------+
| +--+ | | |
| | | <--------------------------------- SELECT...
| +--+ | | |
| | Copy-On-Write | |
| +--+ | (first time only) | +--+ |
UPDATE... --> | | - - - - - - - - - - - -> | | <--- SELECT...
| +--+ | | +--+ |
+--------+ +--------+
How Data Can Be Recovered from a Database Snapshot
Undelete a row | Insert original data from snapshot |
Undo an update | Get original values from snapshot |
Recover a dropped object | Generate script from snapshot, then copy data |
Revert to snapshot | Restore database from snapshot |
Lesson 6: System Databases and Disaster Recovery
Considerations for Backing Up System Databases
Considerations for Restoring System Databases
Restore master, model, and msdb databases from backup if available
If no valid backup of the master database exists, re-create using:
Reattach undamaged databases rather than restoring
How to Restore the master Database