Back Up Types

You might also like

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 35

Database Recovery Models

Recovery models change the behavior of the


transaction log, what backups can be performed,
and how data is recovered.
Full Recovery Model
• In the Full recovery model, all activity that
affects the database is logged in the
transaction log in some way or another.
Bulk-Logged Recovery Model
• In the Bulk-Logged recovery model, the following
database operations are minimally logged:
❑ Index creation
❑ Index rebuild
❑ Bulk copy operations
❑ BULK INSERT
❑ SELECT INTO
❑ BLOB operation
Cont…
• Minimal logging means that the operations listed
are logged as having occurred, but the individual
rows affected are not logged.
• In addition to the record of the operation being
logged, a record of the physical extents allocated
or affected by the operation is recorded in the
transaction log.
• During the next BACKUP LOG event, the affected
physical extents are copied to the log backup.
Disadvantage
• Bulk-Logged recovery keeps the log smaller by
minimally logging data-intensive operations,
but the log backups can actually be larger.

• Because the log backups rely on the physical


data being intact during the log backup, if the
disks are damaged or unavailable, the log
backup will fail.
Advantage
• In Bulk-Logged recovery, the transaction log
contains a record of all the fully logged
modifications made to the database, and the
identification of changed extents modified by
minimally logged operations.

• Like the transaction log in the Full recovery


model, the transaction log in Bulk-Logged
recovery is available to restore transactions in
the event of a database failure.
Simple Recovery Model
• In the Simple recovery model, the inactive
portion of the log is truncated every time SQL
Server issues a checkpoint.
Advantages
• Because the inactive portion of the log is
basically cleared of every checkpoint, the log
should never grow, and should never need to
be managed.
Disadvantages
• However, the transaction log cannot be
backed up and used for data recovery,
because it does not have a complete record of
all the transactions that have modified the
database.
SQL Server 2005 Database Backup
• SQL Server 2005 backups can be performed
during normal database activity.Backups can
be sent to disk or tape.

BACKUP DATABASE SmallWorks


TO DISK = ‘C:\SQLBackups\FullSmallWorks.BAK’
WITH DESCRIPTION = ‘SmallWorks DB Full
Backup’;
Creating Database Back-Up
• Expand the Databases and then the System
Databases nodes in the Object Explorer of
Management Studio.

• Right-click the Master database, click Tasks, and


click Backup... to launch the Back Up Database
dialog .

• Click the Remove button to remove the default


backup location.
Cont….
• Click the Add button to specify a new
destination for the database backup.

• In the Select Backup Destination dialog type


in a new destination for the backup, such as
C:\SQLBackups\FullMaster.BAK.

• Click OK to start the backup.


SQL Server 2005 Backup Types
• Full Backup:-The Full backup simply backs up all
the data in the database and records all database
file locations.

• The advantage of the Full backup is that it is


exceptionally simple.

• However, Full backups take longer than other


backup methods, and typically result in the same
unchanged data being backed up over and over
again, along with the new and updated data.
Query
• BACKUP DATABASE SmallWorks
• TO DISK
=‘C:\SQLBackups\SmallWorksFull.BAK’
• WITH DESCRIPTION = ‘SmallWorks FULL
Backup’;
Differential Backup
• Differential backups are used to back up only
the data that has changed since the last Full
backup.
• Advantages:-Less time
• Disadvantage:-If just 1 byte of a 64K extent is
modified, the Differential backup will backup
the entire extent.
Query
• BACKUP DATABASE SmallWorks
• TO DISK =
‘C:\SQLBackups\SmallWorksDiff.BAK’
• WITH DIFFERENTIAL, DESCRIPTION =
‘SmallWorks Differential Backup’;
File/Filegroup Backup
• When a database is divided across many files and
filegroups, these files and filegroups can be
backed up individually.

BACKUP DATABASE SmallWorks


FILEGROUP = ‘SWUserData1’
• TO DISK =
‘C:\SQLBackups\SmallWorksUserData1FG.BAK’
• WITH DESCRIPTION = ‘SmallWorks SWUserData1
Filegroup Backup’;
File/Filegroup with Differential
• This option works exactly like the typical Differential
backup; only the changes to the file or filegroup since
the last complete File or Filegroup backup are
captured.

BACKUP DATABASE SmallWorks


FILEGROUP = ‘SWUserData1’
TO DISK =
‘C:\SQLBackups\SmallWorksUserData1FGDIFF.BAK’
WITH DIFFERENTIAL, DESCRIPTION = ‘SmallWorks
Filegroup Differential Backup’;
Transaction Log Backup
Transaction Log backups come in three forms:

Pure Log backup—A Pure Log backup contains


only transactions and is completed when the
database is in Full recovery model or Bulk
Logged recovery model, but no bulk operations
have been executed.
Cont…
Bulk Log backup—Bulk Log backups contain both
transactional data and any physical extents modified by
bulk operations while the database was in Bulk-Logged
recovery.

Tail Log backup—Tail Log backups are completed when


the database is in Full or Bulk-Logged recovery to capture
all transaction log records that have not yet been backed
up. It is possible in some instances to execute a Tail Log
backup even if the database is damaged.
Partial Backup
• A Partial database backup consists of the Primary
filegroup, read-write filegroups, and any read-
only filegroup specified.

• The idea behind the Partial backup is that the


Primary filegroup and all the filegroups subject to
modifications can be backed up together, leaving
the filegroups that do not change to be backed
up separately, saving both time and backup
media space.
Query
• BACKUP DATABASE SmallWorks
READ_WRITE_FILEGROUPS
• TO DISK =
‘C:\SQLBackups\SmallWorksPartial.BAK’
• WITH DESCRIPTION = ‘Partial Backup of all
Read/Write filegroups’;
Copy Only Backup
• Copy Only backups can be performed on database
files and transaction logs to create a backup without
affecting the chain of backups required to restore a
database.

For example, if a copy of the database is needed


for test and development, a Copy Only backup can be
performed so as not to break the backup chain.
Query
• BACKUP DATABASE SmallWorks
• TO DISK =
‘C:\SQLData\SmallWorksCopyOnly.BAK’
• WITH COPY_ONLY, DESCRIPTION = ‘Copy only
backup’;
Backup Options
• Backup Stripe
• Mirrored Backup
Backup Strategies
• The various backup types provided by SQL
Server 2005 can be used in different
combinations to create a variety of backup
strategies
Full Backup Only
• The Full backup strategy uses periodic Full
database backups .
Full Backup with Differential
• Because only data modified since the last Full
backup is copied to the backup media,
the periodic Differential backups will be
smaller when compared to the Full backups
and will take less time to execute
Full Backup with Transaction Log
• The disadvantage of the Full and Full with
Differential plans are that they expose the
database to the risk of data loss equal to the
periodicity of the backup.

• The transaction log must be periodically


backed up to prevent it from growing too
large or filling up
Full and Differential Backup with
Transaction Log
• The disadvantage of performing several Transaction
Log backups between Full backups is that the Full
backup and all the logs must be sequentially restored.

• To minimize this issue, a Differential backup can be


performed to capture all the changes to the database
since the last full backup.

• To restore the database, the log backups between the


Full and the Differential can be ignored.
Cont…
• File and Filegroup Backup

• Filegroup with Differential

• Partial Backup
Restoring Databases
• The Data Copy phase, where data pages are copied
from the backup media to the data file.

• The Redo phase, where the record of committed


transactions are restored from a log backup.

• The Undo phase, where uncommitted transactions


are rolled back from a log backup.
Restoring User Databases
• Full Restore
• Full with Differential Restore.
• Full with Transaction Log Restore.
• Full and Differential with Transaction Log
Restore.
• File and Filegroup Restore.
• Partial Restore.
• Point-in-Time Restore
Database Snapshots
• A snapshot is a point-in-time, static, read-only view
of a database.

• When the database snapshot is initially created, near


identical data files are created to hold the contents
of the snapshot. The difference in the data files is
that they have separate physical locations than the
source database, and they initially consume very
little disk space.
Database Snapshot Limitations
• Database snapshots cannot be backed up.

• Database snapshots cannot be modified.

• Source databases cannot be dropped while a snapshot


exists.

• Source databases cannot be restored to a point in time


prior to the creation of the snapshot while
the snapshot exists.

You might also like