Thông tin tài liệu
LESSON: 2A
BACKUP AND RECOVERY IN
SQL SERVER 2000
Objectives
Backup and Recovery in SQL Server 2000
Objectives
In this lesson, you will learn about:
•
•
©NIIT
Performing backup operations
Performing recovery operations
Backup and Recovery in SQL
Server 2000
Lesson 2A / Slide 1 of 34
In this lesson, you will learn about:
Performing backup operations
Performing recovery operations
2A.1
Administering and Troubleshooting SQL Server 2000
Backup and Recovery in SQL Server 2000
Pre-Assessment Questions
©NIIT
1.
Which of the following server roles includes the members of Windows
built-in Administrators group by default?
a)
serveradmin
b)
securityadmin
c)
sysadmin
d)
processadmin
2.
Which of the following fixed database roles can add, delete, and modify
objects in a database using the Transact-SQL statements?
a)
db_owner
b)
db_ddladmin
c)
db_securityadmin
d)
db_accessadmin
Backup and Recovery in SQL
Server 2000
Lesson 2A / Slide 2 of 34
Administering and Troubleshooting SQL Server 2000
2A.2
Backup and Recovery in SQL Server 2000
Pre-Assessment Questions
©NIIT
2A.3
3.
Which of the following Transact-SQL Statements associated with the
members of the sysadmin and dbcreator server roles?
a)
CREATE TABLE
b)
BACKUP DATABASE
c)
CREATE DATABASE
d)
CREATE TRIGGER
4.
When a new user-defined database role is created, the entry is made in
which one of the following system tables?
a)
sysusers
b)
syspermissions
c)
sysdatabases
d)
sysmembers
Backup and Recovery in SQL
Server 2000
Lesson 2A / Slide 3 of 34
Administering and Troubleshooting SQL Server 2000
Backup and Recovery in SQL Server 2000
Pre-Assessment Questions
5.
©NIIT
Which table stores the details about the stored procedures, triggers,
and views?
a)
syscomments
b)
sysusers
c)
syspermissions
d)
sysdatabases
Backup and Recovery in SQL
Server 2000
Lesson 2A / Slide 4 of 34
Administering and Troubleshooting SQL Server 2000
2A.4
Backup and Recovery in SQL Server 2000
Solutions to Pre-assessment Questions:
Ans 1. c. sysadmin
Ans 2. b. db_ddladmin
Ans 3. c. CREATE DATABASE
Ans 4. a. Sysusers
Ans 5. a. Syscomments
©NIIT
Backup and Recovery in SQL
Server 2000
Lesson 2A / Slide 5 of 34
INSTRUCTOR NOTES
Start the session by introducing the concept of backups to the students. Tell the
students about the importance of the backup operations. Next, discuss the different
types of backup devices that can be used to back up databases in SQL Server 2000.
Then, elaborate on how to create a backup device using the SQL Server 2000
Enterprise Manager in detail. You can create a backup device, Mac using the SQL
Server 2000 Enterprise Manager. Also tell the students that a backup device can be
created using the sp_adddumpdevice system stored procedure of Transact-SQL and
explain the syntax of the sp_adddumpdevice system stored procedure. Next, discuss
about the types of backup available. Explain each type in detail and tell the students
about the situations where each type of backup is used and when each backup is
performed.
Ensure that the following datafiles are installed on the student nodes:
Employee.mdb
2A.5
Administering and Troubleshooting SQL Server 2000
Introduction to Backup Operations
Backup and Recovery in SQL Server 2000
Introduction to Backup Operations
©NIIT
•
You perform backup operations as a precautionary measure to prevent
data loss.
•
A backup is a copy of the data that you store at a location other than
the hard disk of your computer.
•
You can back up data on a magnetic tape, magnetic disk, or the hard
disk of another computer system in the Local Area Network (LAN).
Backup and Recovery in SQL
Server 2000
Lesson 2A / Slide 6 of 34
You perform backup operations as a precautionary measure to prevent data loss. A
backup is a copy of the data that you store at a location other than the hard disk of
your computer. You can back up data on a magnetic tape, magnetic disk, or the hard
disk of another computer system in the Local Area Network (LAN).
Administering and Troubleshooting SQL Server 2000
2A.6
Reasons for Taking Backups
Backup and Recovery in SQL Server 2000
Reasons for Taking Backups
•
The following are the reasons for taking backup of your data:
•
•
•
©NIIT
Hardware Failure
Natural Disasters
Intentional or Accidental Data Loss
Backup and Recovery in SQL
Server 2000
Lesson 2A / Slide 7 of 34
The following are the reasons for taking backup of your data:
Hardware Failures: This refers to data loss due to failure of hardware devices,
such as hard disk, processor, or input/output devices. The hardware devices are
expected to work without failure for a specific time period that is termed as
Mean Time Between Failure (MTBF). The MTBF is measured in hours and
indicates the average time a computer system can work without failure. This
average time is calculated by dividing the total number of functional hours
observed by the total number of failures. You can calculate the average life cycle
of your computer and perform backups periodically.
Natural Disasters: This refers to data loss due to unpredictable situations, such
as flood, fire, and earthquakes. Since these situations are unpredictable, you
need to take backups on a regular basis.
Intentional or Accidental Data Loss: This refers to data loss due to intentional or
accidental negligence of the user, such as accidental use of the DELETE
statement or the DROP DATABASE statement.
2A.7
Administering and Troubleshooting SQL Server 2000
Identifying Backup Devices
Backup and Recovery in SQL Server 2000
Backup Device
•
•
•
©NIIT
A backup device is a medium that stores the backup data. A backup
device can be a temporary device or a permanent device.
You use a temporary backup device only once, whereas you use a
permanent backup device to repeatedly store backups from the
available backup devices.
SQL Server 2000 uses the following types of backup devices:
• Disk Devices
• Tape Devices
Backup and Recovery in SQL
Server 2000
Lesson 2A / Slide 8 of 34
A backup device is a medium that stores the backup data. A backup device can be a
temporary device or a permanent device. You use a temporary backup device only
once, whereas you use a permanent backup device to repeatedly store backups from
the available backup devices. SQL Server 2000 uses the following types of backup
devices:
Disk Devices: A disk device is the local disk of your computer system or another
computer system that is connected through LAN. A disk device should be
different from the disk storing the SQL Server 2000 data. They are usually used
to back up large databases of size 20 GB or more.
Tape Devices: Tape devices are magnetic tapes that are physically connected to
the computer, running SQL Server 2000. They are usually used to backup small
size databases, for example databases of size less than 10 GB.
Both, tape and disk devices can be used as temporary or permanent
backup devices.
Administering and Troubleshooting SQL Server 2000
2A.8
Creating a Permanent Backup Device Using the
SQL Server Enterprise Manager
Backup and Recovery in SQL Server 2000
Creating a Permanent Backup Device
using the SQL Server Enterprise
Manager
• In SQL Server, you can create a permanent backup device using the SQL
Server Enterprise Manager.
©NIIT
2A.9
Backup and Recovery in SQL
Server 2000
Lesson 2A / Slide 9 of 34
Administering and Troubleshooting SQL Server 2000
Backup and Recovery in SQL Server 2000
Creating a Permanent Backup Device
using the SQL Server Enterprise
Manager (Contd.)
©NIIT
Backup and Recovery in SQL
Server 2000
Lesson 2A / Slide 10 of 34
In SQL Server, you can create a permanent backup device to store the backup files
using the SQL Server Enterprise Manager. The following steps enable to create a
permanent backup device using the SQL Server Enterprise Manager:
1. Select StartÆ All ProgramsÆ Microsoft SQL ServerÆ Enterprise
Manager, to open the Enterprise Manager.
2. From the Console Root, expand the Microsoft SQL Servers option and then
expand the SQL Server Group option.
3. Expand the SQL Server default instance option and expand the Management
option.
4. Right-click the Backup option, to display the pop-up menu, as shown.
Administering and Troubleshooting SQL Server 2000
2A.10
5. From the pop-up menu, select the New Backup Device option, to open the
Backup Device Properties-New Device dialog box.
6. In the Name text box of the Backup Device Properties dialog box, enter
Mac as the name of the backup device that you want to create. The backup
file name is automatically displayed in the File name text box (C:\Program
Files\Microsoft SQL Server\MSSQL\backup), as shown.
2A.11
Administering and Troubleshooting SQL Server 2000
7. Click the OK button to close the Backup Device Properties-New Device
dialog box.
8. Verify that the details pane of the SQL Server Enterprise Manager displays
the newly created backup device.
Administering and Troubleshooting SQL Server 2000
2A.12
Creating a Permanent Backup Device Using
Transact-SQL
Backup and Recovery in SQL Server 2000
Creating a Permanent Backup Device
using Transact-SQL
•
You can also create a permanent backup device using the
sp_adddumpdevice system stored procedure of the Transact-SQL. The
following is the syntax of the sp_adddumpdevice stored procedure:
sp_addumpdevice [@devtype =] ‘device_type’, [@logicalname =]
‘logical_name’, [@physicalname =] ‘physical_name’]
©NIIT
Backup and Recovery in SQL
Server 2000
Lesson 2A / Slide 11 of 34
You can also create a permanent backup device using the sp_addumpdevice system
stored procedure of the Transact-SQL. The following is the syntax of the
sp_addumpdevice stored procedure:
sp_addumpdevice [@devtype =] ‘device_type’, [@logicalname =]
‘logical_name’, [@physicalname =] ‘physical_name’]
In the above syntax:
The device_type variable refers to the type of backup device that you want to
use. The value of this variable can be disk, tape or pipe. The device type has to
be specified within single quotes.
The logical_name variable refers to the name of the backup device, and is used
by the operating system.
The physical_name refers to the physical name of the backup device and is used
by the database administrator or the user.
2A.13
Administering and Troubleshooting SQL Server 2000
Backup devices are not associated with a specific database.
Identifying the Types of Backups
Backup and Recovery in SQL Server 2000
Types of Backups
•
•
•
•
•
•
Full
Differential
Filegroup
Differential filegroup
Transaction log
Parallel striped
©NIIT
Backup and Recovery in SQL
Server 2000
Lesson 2A / Slide 12 of 34
SQL Server 2000 provides various methods to back up databases, filegroups, and
transaction log files. The different backup methods of SQL Server are:
Full
Differential
Filegroup
Differential filegroup
Transaction log
Parallel striped
Administering and Troubleshooting SQL Server 2000
2A.14
Full Backup
Full backup refers to the backup of the entire SQL Server 2000 database. A full backup
operation takes the backup of the database, data files, and the transaction log files. It
also takes the backup of the database objects, system and user-defined tables, and
indexes. A full backup is predominantly used to backup data of read-only databases.
The full backup operation is necessary for a database because it provides a baseline
for recovery of data, in the event of a system failure. As a result, all other methods of
backup are performed only after performing a full database backup. It is also a
prerequisite for performing the transaction log and differential backups. A full backup
is required to rebuild databases in the case of system failure. It is also required when
you need to store new data without deleting the old data. For example, you can
perform a full database backup at the end of a financial year and use the same
database for storing data of the next financial year. You can either use Transact-SQL
or SQL Server Enterprise Manager to perform a full backup.
Differential Backup
Differential backup records and stores all the changes made to a database and
database objects, since the last full backup of the database. You can take a differential
backup only after performing a full backup. This backup operation is faster and
requires less memory space than the full backup operation because it records the last
backup. You can perform a differential backup to store the changes to the database,
database objects, filegroups, or the transaction log files since the last full database
backup. You can also use the differential backup of user databases to restore them to
a specific state at a given point-of-time. You can perform a differential backup for a
database, filegroups, and transaction log files using either the Transact-SQL or the
SQL Server Enterprise Manager.
Filegroup Backup
Filegroup backup makes copies of specific data files or the data files contained in a
single filegroup. You perform a filegroup backup for Very Large Databases (VLDBs)
when there is a time and memory space constraint and full database backup cannot be
performed. You need to carefully plan a filegroup backup so that the related data and
indexes are backed up together. Filegroup backup is performed when you want to
backup selected data files of a specific database or when the database is of the Very
Large-Scale Database (VLDB) category. Similar to differential backup, you can either
use the Transact-SQL or the SQL Server Enterprise Manager to perform a filegroup
backup.
2A.15
Administering and Troubleshooting SQL Server 2000
Differential Filegroup Backup
Differential filegroup backup refers to the backup of all the changes made to a
filegroup since the last filegroup backup. Differential filegroup backup is faster and
requires less memory space as compared to a filegroup backup because it records only
the most recent changes made to the filegroup. Differential filegroup backup is
performed when you want to backup the most recent changes made to selected data
files of specified database. You can perform this backup using either the Transact-SQL
or the SQL Server 2000 Enterprise Manager.
Transaction Log Backup
Transaction log backup is a sequential record of the information stored in a transaction
log file. A transaction log backup depends on the size of the transaction log file, the
rate at which the transactions occurs, and the fault tolerance of the system.
Transactional log backup is performed to rebuild the system and user databases.
Transaction log backup is also used to monitor and optimize the performance of
databases. You can use either the Transact-SQL or the SQL Server 2000 Enterprise
Manager to perform this backup.
Parallel Striped Backup
Parallel striped backup is used to speed up the backup operation. In this type of
backup, you use multiple backup devices to backup multiple data files, filegroups, and
transaction log files. You can use both permanent as well as temporary backup devices
to perform the backup operation. However, the backup devices should be of the same
type, either a disk or tape device. Parallel striped backup is generally used for the full
backup of Very Large Databases (VLDBs).
The members of the sysadmin and dbcreator server roles have the
permission to perform backup operations. In addition to the
members of the server roles, members of db_owner and
db_backupoperator have the permission to perform the backup
operation.
The system databases should be backed up in situations like virus
attacks and security concerns because unauthorized access of data
can corrupt the information stored in SQL. This is because system
databases stores information about all user databases and the
functionality of SQL Server. The backup of user database on the
other hand is done on a periodical basis to avoid any accidental loss
of data.
Administering and Troubleshooting SQL Server 2000
2A.16
INSTRUCTOR NOTES
You can now discuss how to perform a full database backup operation using the SQL
Server 2000 Database Backup wizard. To help the students get a better understanding
of the full database backup operation, present the students with an imaginary
business problem that requires performing of a full database backup operation.
Discuss the solution of the problem in detail by breaking the solution into small tasks.
Now, you can tell the students how to perform different types of backup operations
using the SQL Server Enterprise Manager or Transact-SQL. While explaining the
Transact-SQL method to perform backup operations, explain the syntax of the
Transact-SQL statements with examples. After discussing the various methods of
performing different types of backup operations, tell the students about the
precautions that should be undertaken while performing a backup operation.
2A.17
Administering and Troubleshooting SQL Server 2000
PERFORMING DATABASE
BACKUP USING THE
DATABASE BACKUP WIZARD
Backup and Recovery in SQL Server 2000
Performing Database Backup Using the
Database Backup Wizard
According to the security policy of Mac Aluminium, Inc., the administration department
has been asked to design a backup plan. The backup plan will use the Database Wizard
of SQL Server 2000 Enterprise Manager for taking a full backup of the Master database
and name the media set, disk device, and backup as Mac. The new full backup should be
appended to the existing backup in the disk, Mac, and should be verified after the
backup operation is complete. The backup plan includes a schedule for performing the
backup on every Sunday at 12:00 AM.
©NIIT
Backup and Recovery in SQL
Server 2000
Lesson 2A / Slide 13 of 34
Problem Statement
According to the security policy of Mac Aluminium, Inc., the administration department
has been asked to design a backup plan. The backup plan will use the Database
Wizard of SQL Server 2000 Enterprise Manager for taking a full backup of the Master
database and name the media set, disk device, and backup as Mac. The new full
backup should be appended to the existing backup in the disk, Mac, and should be
verified after the backup operation is complete. The backup plan includes a schedule
for performing the backup on every Sunday at 12:00 AM.
Administering and Troubleshooting SQL Server 2000
2A.18
Solution
Backup and Recovery in SQL Server 2000
Task List
•
•
•
•
©NIIT
Start the Database Backup Wizard
Select the type of backup to be performed
Select the backup device to be used
Verify the backup operation
Backup and Recovery in SQL
Server 2000
Lesson 2A / Slide 14 of 34
To solve the preceding problem, perform the following tasks:
1. Start the Database Backup Wizard.
2. Select the type of backup.
3. Select the backup device.
4. Verify the backup operation.
2A.19
Administering and Troubleshooting SQL Server 2000
1: Start the Database Backup Wizard
Create a backup device named Mac before you perform the steps. To
create the backup device refer to the section “Creating a Permanent
Backup Device using the SQL Server Enterprise Manager
Action:
1. Select StartÆ All ProgramsÆ Microsoft SQL ServerÆ Enterprise
Manager, to open the Enterprise Manager.
2. From the Tools menu, select the Wizards option to display the Select
Wizard dialog box, as shown.
Administering and Troubleshooting SQL Server 2000
2A.20
3. Expand the Management option and select Backup Wizard, as shown.
4. Click the OK button to display the Welcome to the Create Database
Backup Wizard screen, as shown.
5. Click the Next button to display the Select Database to Backup screen.
2A.21
Administering and Troubleshooting SQL Server 2000
2: Select the type of backup
Action:
1. In the Database drop-down list of the Select Database to Backup screen,
select the default master as the name of the database, as shown.
If you want to backup any other database, you can select the particular database from
the Database drop-down list.
2. Click the Next button to display the Type Name and Description for
Backup screen, as shown.
Administering and Troubleshooting SQL Server 2000
2A.22
The Type Name and Description for Backup screen displays the following
two textboxes:
Name: This text box automatically displays the name of the database that
needs to be backed up.
Description: This text box allows you to enter the description of type of
backup required.
3. Verify that master backup appears in Name text box. Enter Full database
backup in the Description text box.
4. Click the Next button to display Select Type of Backup screen, as shown.
2A.23
Administering and Troubleshooting SQL Server 2000
The Select Type of Backup screen displays the following two options:
Differential backup
Transaction log backup
The Differential database and Transaction log backup options are disabled
in the case of master databases. These two options would also be disabled if
you are performing the backup for the first time. Till you perform a full
database backup, you cannot perform either a differential backup or a
transactional log backup, for a user created database.
5. Select the Database backup-backup the entire database option. Click the
Next button to display the Select Backup Destination and Action screen.
3: Select the backup device
The Select Backup Destination and Action screen allows you to select the backup
device that you want to use for the backup operation. In the Select backup device
section, you can either select a Tape, File, or Backup device option. The screen
displays the default location for a file. You can also select the Append to the backup
media option to append the current backup set to any existing backup sets on the
backup media. Similarly, the Overwrite the backup media option allows you to
overwrite the current backup set on any existing backup sets on the backup media. In
addition, the Read and verify the integrity of the backup after backup option
verifies the backup files that have been written and are readable.
Action:
1. In the Select backup device section of the Select Backup Destination and
Action screen, select the Backup device option and select the name Mac
from the listbox, as shown.
Administering and Troubleshooting SQL Server 2000
2A.24
2. In the Properties section, verify that the Append to the backup media
option is selected. Select the Read and verify the integrity of the backup
after backup option.
3. Click the Next button to display the Backup Verification and Scheduling
screen.
4. In the Backup Verification and Scheduling screen, verify that the Check
media set name and backup set expiry date option is selected. Enter the
name, Mac in the Media set name text box.
2A.25
Administering and Troubleshooting SQL Server 2000
5. In the Scheduling section of the Backup Verification and Scheduling
screen, select the Schedule option. This automatically sets the weekly
schedule as Once every week at Sunday, at 12:00 AM, as shown.
6. Click the Next button to display the Completing the Create Database
Backup Wizard screen, as shown.
4: Verify the backup operation
Action:
The Completing the Create Database Backup Wizard screen displays a text box
that lists all the specified settings. Click the Finish button to complete the backup
Administering and Troubleshooting SQL Server 2000
2A.26
operation. The details pane lists the backup device Mac along with the other backup
devices. It shows backup has been successfully created and will run on every Sunday
at 12:00 A.M.
2A.27
Administering and Troubleshooting SQL Server 2000
PERFORMING BACKUPS USING
ALTERNATE METHODS
Backup and Recovery in SQL Server 2000
Other Ways to perform Backup
©NIIT
•
You can perform backup in other ways:
• Using Tools menu of SQL Server 2000 Enterprise
Manager
• Transact-SQL
•
SQL Server 2000 enables you to perform the following types of
backups using Transact-SQL:
• Full database backup
• Differential database backup
• Filegroup backup
Backup and Recovery in SQL
Server 2000
Lesson 2A / Slide 15 of 34
Administering and Troubleshooting SQL Server 2000
2A.28
Backup and Recovery in SQL Server 2000
Other Ways to perform Backup
(Contd.)
•
•
•
•
You can perform a full database backup of the SQL Server 2000 database.
BACKUP DATABASE TO =
You can use BACKUP DATABASE statement of Transact-SQL to perform a
differential database backup.
BACKUP DATABASE TO WITH
DIFFERENTIAL
The BACKUP DATABASE statement of Transact-SQL can be used to perform
filegroup backups, if it is accompanied with a FILEGROUP keyword.
BACKUP DATABASE FILEGROUP = TO
You can perform a transaction log backup using the BACKUP LOG statement of
the Transact-SQL.
BACKUP LOG TO
©NIIT
Backup and Recovery in SQL
Server 2000
Lesson 2A / Slide 16 of 34
You can also perform backup by:
Using Tools menu of SQL Server 2000
Enterprise Manager
Using Transact-SQL
Using Tools Menu of SQL Server 2000 Enterprise
Manager
To take backups using SQL Server 2000 Enterprise Manager, perform the following
steps:
1. Select StartÆ All ProgramsÆ Microsoft SQL ServerÆ Enterprise
Manager, to open the Enterprise Manager.
2. From the Tools menu, select the Backup Database option, to open the SQL
Server Backup dialog box.
The SQL Server Backup dialog box consists of the General and Options
tabs.
2A.29
Administering and Troubleshooting SQL Server 2000
You can also display the SQL Server Backup dialog box by rightclicking the Database option from the Console Root and selecting
the All TasksÆ Backup database option from the pop-up menu
that is displayed.
3. In the Database drop-down list of the General tab, enter the name of the
database that needs to be backed up, as shown. Then, enter the name of the
backup in the Name text box and the type of backup to be performed in the
Description text box.
4. In the Backup section of the General tab, select the required backup option.
You can select other types of backup operations available, such as
File and filegroup backup, Transaction log backup, and
Database-differential backup, from the Backup section. The rest
of the backup process using the Enterprise Manager remains the
same for all other types of backups.
For the first time you need to take a complete database backup. Till
the time you take a complete database backup the other options in
the backup section of the SQL Server Backup dialog box appear
deselected. The options for File and filegroup backup,
Transaction log backup, and Database-differential are activated
and available for selection only after a complete database backup.
Administering and Troubleshooting SQL Server 2000
2A.30
5. The Destination section of the General tab displays a text box that requires
you to enter the backup device for the backup. To enter the backup device,
click the Add button. The Select Backup Destination dialog box appears
with the File name and Backup device options.
6. Select the Backup device option and click the OK button. The text box in the
Destination section displays the backup device selected.
7. In the Overwrite section of the SQL Server Backup dialog box, select the
Append to media option. Then, select the Schedule option in the Schedule
section. SQL Server 2000 automatically provides you with a weekly schedule
for performing backups.
8. Activate the Options tab, as shown.
2A.31
Administering and Troubleshooting SQL Server 2000
9. Select the Verify backup upon completion option and verify that the Check
media set name and backup set expiration option is selected. Enter the
media set name in the Media set name text box.
10. Click the OK button to complete the backup operation. On successful
completion of the backup operation, a dialog box is displayed containing the
The backup operation has been completed successfully message, as
shown.
11. Click the OK button to close the message box.
Administering and Troubleshooting SQL Server 2000
2A.32
The backup of any database provides you with the information about
the database activities, such as the most recent transactions, check
points issued in the database, and oldest active transaction log
record. It also provides information about the original database, its
location, and its schema and structure.
Using Transact-SQL
SQL Server 2000 enables you to perform the following types of backups using
Transact-SQL:
Full database backup
Differential database backup
Filegroup backup
Transactional log backup
Full Database Backup
You can perform a full database backup of the SQL Server 2000 database using the
BACKUP DATABASE statement of Transact-SQL. The following is the syntax of the
BACKUP DATABASE statement:
BACKUP DATABASE TO =
In the above syntax:
The database_name variable refers to the database for which backup needs to
be performed.
The backup_device_name variable refers to the name of the backup device.
The path variable refers to the location of the specified backup device.
For example, you can use the following statement to perform a full database backup of
the Employee database and store it in the Full.bak file:
BACKUP DATABASE Employee TO Disk = ‘C:\MSSQL\Full.bak’
You can also verify the backup taken. The following is the syntax of the Transact-SQL
statements to verify a full database backup:
BACKUP DATABASE TO
RESTORE VERIFYONLY FROM
In the above syntax:
The database_name variable refers to the database for which the backup has to
be performed.
2A.33
Administering and Troubleshooting SQL Server 2000
The backup_filename variable refers to the file that stores the database backup.
The VERIFYONLY keyword verifies the backup stored in the backup file.
For example, you can use the following statement to perform a full database backup of
the employee database and store it in the Mac file. The backup data is verified after
the completion of the backup operation:
BACKUP DATABASE Employee TO Mac
RESTORE VERIFYONLY FROM Mac
Differential Database Backup
You can use BACKUP DATABASE statement of Transact-SQL to perform a differential
database backup. The following is the syntax for performing a differential database
backup using BACKUP DATABASE statement:
BACKUP DATABASE TO WITH DIFFERENTIAL
In the above syntax:
The database_name variable refers to the database for which a differential
backup has to be performed.
The backup_filename variable refers to the file that stores the full database
backup.
The WITH DIFFERENTIAL keyword performs the differential backup of the
database.
For example, you can use the following statement to perform a differential backup of
the Employee database and store the backup in the Mac backup file:
BACKUP DATABASE Employee TO Mac WITH DIFFERENTIAL
Filegroup Backup
The BACKUP DATABASE statement of Transact-SQL can be used to perform filegroup
backups, if it is accompanied with a FILEGROUP keyword.
The following is the syntax for performing a filegroup backup using the BACKUP
DATABASE statement:
BACKUP DATABASE FILEGROUP = TO
In the above syntax:
The database_name variable refers to the database for which a filegroup backup
has to be performed.
Administering and Troubleshooting SQL Server 2000
2A.34
The FILEGROUP keyword indicates that a filegroup backup has to be performed.
The filegroup_name variable refers to the filegroup that needs to be backed up.
The Filegroup_backup_filename variable refers to the file that stores the
filegroup backup.
For example, you can use the following statement to perform a backup of the
filegroup, EmpFG in the Employee database and store it in EmpFGBackup file:
BACKUP DATABASE Employee FILEGROUP = EmpFG TO EmpFGBackup
To perform the filegroup backup, verify that the default recovery
model of database is Full.
Transaction Log Backup
You can perform a transaction log backup using the BACKUP LOG statement of the
Transact-SQL. The following is the syntax of this statement:
BACKUP LOG TO
In the above syntax:
The database_name variable refers to the database whose transaction log file
needs to be backed up.
The transactionlog_backup_filename variable refers to an already existing
backup file. To store the transaction log backup in a new file, create the backup
file and then execute the backup log statement.
For example, you can use the following statement to perform a backup of the
transaction log files of the Employee database and store it in the EmpLogBackup file:
BACKUP LOG Employee TO EmpLogBackup
A transaction log backup is performed when the data files are damaged or lost, or in
the case of system failure. You can perform a transaction log backup by specifying the
NO_TRUNCATE option with the BACKUP LOG statement. Using this option, you can
backup the transaction log files to record the most recent transactions and database
activity up to the time when the data file was damaged or when the system failure
occurred. The following is the syntax of the BACKUP LOG statement with the
NO_TRUNCATE option:
BACKUP LOG TO
NO_TRUNCATE
In the above syntax:
2A.35
Administering and Troubleshooting SQL Server 2000
The database_name variable refers to the database whose transaction log file
needs to be backed up.
The transactionlog_backup_filename variable refers to the file that stores the
transaction log backup.
The NO_TRUNCATE keyword specifies that the transaction log should be backed
up till the time when the system failure occurred or when the data file was
damaged.
Consider the following example:
BACKUP LOG Sales TO SalesLogBackup NO_TRUNCATE
In the above example, the backup of the transaction log file of the Sales database is
performed and it stores the database activity up to the time the data file was
damaged. The backup is stored in the SalesLogBackup file.
To maintain the size of the transaction log, you need to regularly
clear the log by deleting the transaction files. To clear the
transaction log, you use the BACKUP LOG statement with the
TRUNCATE_ONLY or NO_LOG options. These options remove the
inactive part of the transaction log without performing the backup of
the inactive part.
Administering and Troubleshooting SQL Server 2000
2A.36
Precautions for Performing a Backup Operation
Backup and Recovery in SQL Server 2000
Precautions for Performing a Backup
Operation
•
•
•
©NIIT
You should not create or update a database using either the SQL Server
Enterprise Manager or the CREATE DATABASE statement.
You should not increase or decrease the size of the database.
You should not create indexes during a backup operation.
Backup and Recovery in SQL
Server 2000
Lesson 2A / Slide 17 of 34
You need to take the following precautions while SQL Server 2000 performs a backup
operation:
You should not create or update a database using either the SQL Server
Enterprise Manager or the CREATE DATABASE statement.
You should not increase or decrease the size of the database.
You should not create indexes during a backup operation.
2A.37
Administering and Troubleshooting SQL Server 2000
INSTRUCTOR NOTES
Next, introduce the concept of recovery to the students by telling them about the need
to perform a recovery operation. Tell the students about the pre-requisites to perform
an effective recovery operation. Next, tell the students about the physical recovery
models used by SQL Server 2000 in brief. You can then tell the students about the
automatic and manual recovery processes. Briefly, explain both the recovery
processes. While explaining the manual recovery process, discuss its various recovery
options. Now, explain how to restore database using the SQL Server Enterprise
Manager. Provide the students with a business problem that requires restoration of a
database. Explain the solution of the problem in detail. Now, tell the students how to
restore databases and transaction log files using Transact-SQL by giving elaborate
examples. Finally, explain how to restore master database of SQL Server 2000 in
detail.
Administering and Troubleshooting SQL Server 2000
2A.38
PERFORMING RECOVERY OPTIONS
Backup and Recovery in SQL Server 2000
Introducing Recovery Operations
•
•
Recovery operations are performed to recover data lost from a
database.
To perform an effective database recovery operation, the following
conditions should be fulfilled:
•
•
•
©NIIT
2A.39
The system performing a recovery operation should be fault
tolerant.
The working of the databases should be monitored to detect
problems before these problems become unmanageable.
The recovery operation should be planned to identify the
possible disasters and failures that could be encountered and
to perform the database recovery effectively.
Backup and Recovery in SQL
Server 2000
Lesson 2A / Slide 18 of 34
Administering and Troubleshooting SQL Server 2000
Backup and Recovery in SQL Server 2000
Introducing Recovery Operations
(Contd.)
•
•
•
•
The restoration time for the database to be recovered should be
determined.
The backup of the specified database should be verified.
The access to the database should be restricted till the time it is
recovered and restored.
The consistency of the database should be checked before it is
recovered and restored.
©NIIT
Backup and Recovery in SQL
Server 2000
Lesson 2A / Slide 19 of 34
You perform recovery operations as a measure to recover the lost data from the
database. To recover the backed up databases SQL Server 2000 provides several
recovery models and recovery processes. The recovery processes are based on
recovery models.
Recovering Data
Recovery operations are performed to recover data lost from a database. Recovery
operations have to be planned and performed carefully so that the database is
restored in a fully consistent state. The recovery operations are performed in the
following circumstances:
After a backup operation has been performed on a database
Database becomes inconsistent.
Database gets corrupted.
Data loss due to system
failures and natural disasters.
To perform an effective database recovery operation, the following conditions should
be fulfilled:
Administering and Troubleshooting SQL Server 2000
2A.40
The system
performing a recovery operation should be fault tolerant. This will
keep the SQL Server 2000 running in case of minor system failures.
The working of the databases should be monitored to detect problems before
these problems become unmanageable.
The recovery operation should be planned to identify
the possible disasters and
failures that could be encountered and to perform the database recovery
effectively. The following are some of the failures and disasters that could be
encountered.
x Loss of disk containing system files
x Loss of disk containing transaction logs files
x Server failures
x Faulty backup media
x Natural disasters, such as flood, fire, or earthquake
x Faulty restoration device
The restoration time for the database to be recovered should be determined.
The restoration time depends upon the size of the database, use of the
database, and the type of disaster.
The backup of the specified database should be verified. This can be done by
viewing the information about the original database, backup file, their locations,
date and time when the backup was performed, and size of the backup.
The access to the database should be restricted till the time it is recovered and
restored.
The consistency
of the database should be checked before it is recovered and
restored. To check the consistency, you need to backup the transaction log file
and issue checkpoints in the database to indicate that the database is logically
consistent up to that checkpoint.
2A.41
Administering and Troubleshooting SQL Server 2000
Identifying the types of Recovery Models
Backup and Recovery in SQL Server 2000
Recovery Models
•
To recover the backed up databases, SQL Server provides three types of
recovery models:
•
•
•
©NIIT
Full Recovery Model
Bulk Logged Recovery Model
Simple Recovery Model
Backup and Recovery in SQL
Server 2000
Lesson 2A / Slide 20 of 34
To recover the backed up databases, SQL Server provides three types of recovery
models. The recovery process in SQL Server 2000 is based on one of these three
recovery models. The recovery models of SQL Server 2000 are:
Full Recovery Model: This recovery model is used to recover and restore the full
database backup from a damaged backup device provided that the logs are not
damaged. It restores the entire database and the transaction log files using the
full database backup. Since all the transactions are restored, this model requires
large amount of log space.
Bulk Logged Recovery Model: This recovery model is used to recover and restore
the full database backup and is similar to the full recovery model. The only
difference is that this model uses less log space for transactions as compared to
the log space required in the full recovery model. This model uses less log space
for CREATE INDEX and SELECT INTO operations. This is because the log stores
only the existence of these operations as bits in extents. It does not store the
details of the operations in the log.
Administering and Troubleshooting SQL Server 2000
2A.42
Simple Recovery Model: This recovery model is used to recover and restore
small databases that are not accessed frequently. It restores the database using
the full or the differential database backup.
Identifying the types of Recovery Processes
Backup and Recovery in SQL Server 2000
Types of Recovery Process
•
SQL Server 2000 provides the following two types of recovery processes:
•
•
Automatic recovery process
Manual recovery process
©NIIT
Backup and Recovery in SQL
Server 2000
Lesson 2A / Slide 21 of 34
SQL Server 2000 provides the following two types of recovery processes:
Automatic recovery process
Manual recovery process
Automatic Recovery Process
In an automatic recovery process, SQL Server 2000 performs the recovery process
every time it starts. The automatic recovery process checks the active portion of the
transaction log file and ensures that the data in each database is in a logically
consistent state. The process identifies all the successfully completed transactions
from the transaction log file of a database and reapplies these transactions to the
database. It also identifies all the unsuccessful transactions and removes them from
the database. When this process is complete, the automatic recovery process issues a
2A.43
Administering and Troubleshooting SQL Server 2000
checkpoint to indicate that the transaction log is consistent till this checkpoint. After
recovering the transaction log file, SQL Server 2000 extends the automatic recovery
process to recover the system and user databases.
SQL Server 2000 dynamically decides the frequency of issuing a
checkpoint. The more frequently it issues the checkpoints, the
smaller is the part of the transaction log file that it applies and
removes from the database.
Manual Recovery Process
In a manual recovery process, you manually perform a recovery process after a
backup operation. After the recovery operation is complete, the database is in a
logically consistent state.
The manual recovery operation provides the following options:
Database restoration: You can restore a database using the recent full database
backup. You can also restore a differential database backup using the most
recent differential database backup. You can then restore the transaction log file
by using the recent transaction log backup. This process of database restoration
reinstates the entire database without any data loss.
If the recent full database and differential database backups are
damaged, you can still restore the database using the transaction
log backups.
Restoring filegroups: You can manually restore filegroups using the most recent
full database backup. After restoring the filegroups using the most recent full
database backup, restore the transaction log file using the most recent
transaction log backup. This process of database restoration reinstates the
filegroups without any data loss.
To restore the filegroups to a logically consistent state, the filegroup
backups should always be accompanied with the transaction log
backups
Restoring point-in-time: You can restore a database to a specific point-in-time.
To restore a database to a point-in-time, you need to restore the full database
backup from the most recent full database backup and then restore the
transaction log backup from the most recent transaction log backup specifying
the time till which the database has to be restored. This process of database
restoration reinstates the database to the specified point-in-time.
Administering and Troubleshooting SQL Server 2000
2A.44
SQL Server 2000 Enterprise Manager displays the Suspect keyword
below the name of the database, in the Details pane to identify the
corrupt database.
2A.45
Administering and Troubleshooting SQL Server 2000
PERFORMING DATABASE
RESTORATION USING SQL
SERVER ENTERPRISE
MANAGER
Backup and Recovery in SQL Server 2000
Performing Database Restoration
using SQL Server 2000 Enterprise
Manager
A virus has corrupted the Employee database of the Virginia plant. The
administration department of the plant contacts the disaster recovery team to
restore the database. As a full database backup of the EMPLOYEE database had
been taken, the team decides to restore the full database backup and store the
restored database as EMPLOYEE. The administration department wants the team
to restore each data file of the database to its original location and leave the
database operational after the completion of the recovery process. In addition,
the department wants SQL Server 2000 to automatically handle the recovery and
the restoration process.
©NIIT
Backup and Recovery in SQL
Server 2000
Lesson 2A / Slide 22 of 34
Problem Statement
A virus has corrupted the Employee database of the Virginia plant. The administration
department of the plant contacts the disaster recovery team to restore the database.
As a full database backup of the Employee database had been taken, the team decides
to restore the full database backup and store the restored database as Employee. The
administration department wants the team to restore each data file of the database to
its original location and leave the database operational after the completion of the
recovery process. In addition, the department wants SQL Server 2000 to
automatically handle the recovery and the restoration process.
Administering and Troubleshooting SQL Server 2000
2A.46
Solution
Backup and Recovery in SQL Server 2000
Task List
•
•
•
Select the database to be restored.
Restore the database.
Verify the restored database.
©NIIT
Backup and Recovery in SQL
Server 2000
Lesson 2A / Slide 23 of 34
To solve the preceding problem, perform the following tasks:
1. Select the database to be restored.
2. Restore the database.
3. Verify the restored database.
2A.47
Administering and Troubleshooting SQL Server 2000
1: Select the database to be restored
Action:
1. In the SQL Server 2000 Enterprise Manager, expand Console RootÆ SQL
Server GroupÆSQL Server 2000 default instanceÆDatabases option.
2. Right click the Employee database, from the details pane, to display a pop-up
menu.
3.
Select the All TasksÆ Restore database option from the pop-up menu, to
display the Restore database dialog box.
2: Restore the database
Action:
1.
The General tab of the Restore database dialog box is selected by default.
Verify that the Employee database is selected from the Restore as
database drop-down list. Select the From device option from the Restore
section.
Administering and Troubleshooting SQL Server 2000
2A.48
2. In the Parameters section, click the Select Devices button to select the
backup device. The Choose Restore Devices screen appears.
3.
Verify that the Disk option is selected.
4. Click on the Add button to select the backup file to restore. The Choose
Restore Destination screen appears.
5. Verify that File name option is selected. Click the browse button to select the
backup file to restore.
6. The Backup Device Location dialog box appears. Select the file and click
OK.
7. Notice that the file name appears in the File name textbox.
8. Click OK to go back to the previous screen.
9. Notice that the backup file name is appearing in the File name textbox. Click
OK to continue.
10.
2A.49
Activate the Options tab of the Restore database dialog box.
Administering and Troubleshooting SQL Server 2000
11. Enter the location of the database files in the Move to physical file name
column. Ensure that Employee.mdf and Employee_Log.LDF does not exist in
the specified location.
The Options tab also displays the following three options:
Eject tapes(if any) after restoring each backup
Prompt before restoring each backup
Force restore over existing databases
Since the department wants SQL Server to handle the restoration and
recovery process, none of these options have to be selected.
12. In the Recovery completion state section, the Leave the database
operational. No additional transaction logs can be restored option is
selected by default. Then, click the OK button.
13. A message box displays the message, Restore of database ‘Employee’
completed successfully, as shown.
Administering and Troubleshooting SQL Server 2000
2A.50
14. Click the OK button to close the message box.
3: Verify the restored database
Action:
To view the restored database, perform the following steps:
1.
From the Console Root, expand the Databases option of the SQL Server 2000
default instance.
2. Select the Employee database. Double-click the Employee database to view
its components in the details pane.
3.
2A.51
Double-click the Tables option in the details pane to view the tables of the
Employee database.
Administering and Troubleshooting SQL Server 2000
Performing Restoration Using Transact-SQL
Backup and Recovery in SQL Server 2000
Performing Restoration Using
Transact-SQL
•
You can use Transact-SQL to restore the following:
•
•
©NIIT
Database
Transaction log files
Backup and Recovery in SQL
Server 2000
Lesson 2A / Slide 24 of 34
Administering and Troubleshooting SQL Server 2000
2A.52
Backup and Recovery in SQL Server 2000
Performing Restoration Using
Transact-SQL (Contd.)
•
You can restore a SQL Server 2000 database and transaction log files
using the RESTORE DATABASE and the RESTORE LOG statements of
Transact-SQL, respectively.
RESTORE DATABASE FROM
RESTORE LOG < database_name> FROM
©NIIT
Backup and Recovery in SQL
Server 2000
Lesson 2A / Slide 25 of 34
You can use Transact-SQL to restore the following:
Database
Transaction log files
Restoring Databases
You use the RESTORE DATABASE statement of Transact-SQL, to restore a database.
The RESTORE DATABASE statement uses certain options to restore the database.
These options are:
FILE: This option restores a specified backup file from
multiple backup files.
RESTART: This option restarts an interrupted recovery operation.
MOVE…TO: This option is used to specify the location of the restored data files.
REPLACE: This option is used when you need to replace an existing database
with the data of another database.
2A.53
Administering and Troubleshooting SQL Server 2000
The following is the syntax of the RESTORE DATABASE statement:
RESTORE DATABASE FROM =
In the above syntax:
The database_name variable refers to the database to be restored.
The backup_device variable refers to the backup device that stores the database
backup.
The path variable refers to the location of the database backup.
For example, you can use the following statement to perform a backup of the
Employee database and restore it to the disk from the backup file Full.bak:
RESTORE DATABASE Employee FROM Disk = ‘C:\MSSQL\Mac\Full.bak’
Restoring Transaction Log Files
You can restore a SQL Server 2000 database and transaction log files using the
RESTORE DATABASE and the RESTORE LOG statements of Transact-SQL, respectively.
The following is the syntax of the RESTORE DATABASE and RESTORE LOG statements:
RESTORE DATABASE FROM
RESTORE LOG < database_name> FROM
In the above syntax:
The database_name variable refers to the name of the database to be restored.
The database_backup_filename variable refers to the file that stores the
database backup.
The transactionlog_backup_filename variable refers to the file that stores the
transaction log backup.
For example, you can use the following statement to perform a full database backup of
the Employee database and restore it from the EmpFullBackup file. The transaction log
backup of the transaction log file is also performed and the EmpLog is restored from
the EmpLogBackup file:
RESTORE DATABASE Employee FROM EmpFullBackup
RESTORE LOG EmpLog FROM EmpLogBackup
Administering and Troubleshooting SQL Server 2000
2A.54
Restoring the Master Databases
Backup and Recovery in SQL Server 2000
Restoring the Master Databases
For example, you can use the following statement to perform a backup of the
Employee database and restore it to the disk from the backup file Full.bak:
RESTORE DATABASE master FROM Masterfullbackup
©NIIT
Backup and Recovery in SQL
Server 2000
Lesson 2A / Slide 26 of 34
You can restore the master databases of SQL Server 2000. To restore the master
database, perform the following steps:
1. Select StartÆ All ProgramsÆ Microsoft SQL ServerÆ Query Analyzer, to
open the Query Analyzer window.
2. To restore the recent backup of the master database, type the following
command in the Query Analyzer window:
RESTORE DATABASE master FROM Masterfullbackup
To restore a master database, you must start your SQL Server in a
single user mode.
2A.55
Administering and Troubleshooting SQL Server 2000
INSTRUCTOR NOTES
Additional Inputs
Restoring Filegroups Using Transact-SQL
You can restore filegroups using the RESTORE DATABASE statement of Transact-SQL.
The following is the syntax to use the RESTORE DATABASE statement:
RESTORE DATABASE FILE = FROM
. STATS = RESTORE LOG
FROM WITH FILE =
In the above syntax:
The database_name is the name of the database whose filegroups you want to
restore
The data_
restore.
file_name refers to the name of the single data file that you want to
The backup_file_name refers to the file that contains the backup of the data file.
The STATS keyword provides the status of the restoration process each time the
restoration process is completed by the specified percent. The numeric_value
refers to the value that you specify as percent.
The RESTORE LOG keyword restores the transaction log file of the specified
database.
The database_backup_file refers to the file that stores the backup of the
specified database.
FILE keyword takes the numeric value that refers to the backup set in the
backup device.
Administering and Troubleshooting SQL Server 2000
2A.56
Restoring Database to a Specified Point-in-Time
You can restore a SQL Server 2000 database to a specified point-in-time using the
RESTORE DATABASE statement of Transact-SQL. The following is the syntax to use
the RESTORE DATABASE statement:
RESTORE DATABASE < database_name> FROM RESTORE
LOG FROM
STOPAT = < time and date>
In the above syntax:
The STOPAT keyword is used to specify the date and time till which the backup
has to be taken
The database_backup_filename refers to the file that stores the database
backup
The transaction_log filename refers to the transaction log files of the specified
database
The transaction_log backup_filename refers to the backup file that stores the
transaction log backup.
Changing the Database Recovery Model
The database recovery in SQL Server 2000 is based on the recovery model used by
SQL Server 2000. You can change the database recovery model using the ALTER
DATABASE command of Transact-SQL. The following is the syntax of the ALTER
DATABASE statement:
ALTER DATABASE
SET RECOVERY {FULL | SIMPLE | BULK_LOGGED }
In the above syntax:
The database_name variable refers to the database for which the recovery
model has to be changed.
The SET RECOVERY keyword is used to change the recovery
The FULL keyword refers to the full recovery
model.
model.
The SIMPLE keyword refers to the simple recovery model.
The BULK_LOGGED
2A.57
keyword refers to the bulk_logged recovery model.
Administering and Troubleshooting SQL Server 2000
For example:
ALTER DATABASE Northwind SET RECOVERY SIMPLE
The above statement sets the recovery model of the Northwind database to Simple.
INSTRUCTOR NOTES
FAQs
1. Is it possible to recover a non-functional master database?
Ans: No, it is not possible to recover a non-functional master database. You can,
however, recover and restore a partially damaged master database.
2. Which recovery model does SQL Server 2000 Enterprise Edition use as
default?
Ans: SQL Server 2000 Enterprise Edition uses the Full recovery model as a default
recovery model.
3. Why is it essential to regularly perform backups of the Master, msdb, and
model system databases?
Ans: It is essential to perform regular backups of the Master, msdb, and model
system databases because Master database contains information about all the
existing user databases, msdb database contains information about jobs, alerts,
and operators that are used by SQL Server 2000 Agent services, and model
database contains the default configuration of the existing as well as new user
databases.
Administering and Troubleshooting SQL Server 2000
2A.58
SUMMARY
Backup and Recovery in SQL Server 2000
Summary
In this lesson, you learnt that:
©NIIT
2A.59
•
Backup operations are performed to prevent data loss due to the
following reasons:
• Hardware failure
• Natural disaster
• Accidental or intentional damage to data
•
The following are the two types of backup devices:
• Disk backup device
• Tape backup device
Backup and Recovery in SQL
Server 2000
Lesson 2A / Slide 27 of 34
Administering and Troubleshooting SQL Server 2000
Backup and Recovery in SQL Server 2000
Summary (Contd.)
©NIIT
•
The following can be used to create a backup device:
• SQL Server 2000 Enterprise Manager
• Transact-SQL
•
The types of backup operations are:
• Full backup
• Differential backup
• Transaction log backup
• Filegroup backup
• Differential filegroup backup
• Parallel striped backup
Backup and Recovery in SQL
Server 2000
Lesson 2A / Slide 28 of 34
Administering and Troubleshooting SQL Server 2000
2A.60
Backup and Recovery in SQL Server 2000
Summary (Contd.)
•
•
•
•
•
©NIIT
2A.61
A full database backup refers to the backup of the entire SQL Server 2000
database.
Differential backup records and stores all the changes made to a database and
database objects since the last full backup of the database.
Filegroup backup makes copies of specific data files or the data files contained
in a single filegroup.
Differential filegroup backup refers to the backup of all the changes made to a
filegroup since the last filegroup backup.
Transaction log backup is a sequential record of the information stored in a
transaction log file.
Backup and Recovery in SQL
Server 2000
Lesson 2A / Slide 29 of 34
Administering and Troubleshooting SQL Server 2000
Backup and Recovery in SQL Server 2000
Summary (Contd.)
•
Parallel striped backup is used to speed up the backup operation. In
this type of backup, you use multiple backup devices to backup
multiple data files, filegroups, and transaction log files.
•
The following are the alternative methods of performing different types
of backup operations:
•
•
©NIIT
Transact-SQL
The Tools menu of SQL Server 2000 Enterprise Manager
Backup and Recovery in SQL
Server 2000
Lesson 2A / Slide 30 of 34
Administering and Troubleshooting SQL Server 2000
2A.62
Backup and Recovery in SQL Server 2000
Summary (Contd.)
•
Precautions for performing backups:
•
•
•
©NIIT
2A.63
You should not create or update a database using either the
SQL Server Enterprise Manager or the CREATE DATABASE
statement.
You should not increase or decrease the size of the database.
You should not create indexes during a backup operation.
Backup and Recovery in SQL
Server 2000
Lesson 2A / Slide 31 of 34
Administering and Troubleshooting SQL Server 2000
Backup and Recovery in SQL Server 2000
Summary (Contd.)
•
Recovery operations are performed to recover data lost from a
database under the following circumstances:
•
•
•
•
©NIIT
After a backup operation has been performed on a database
Database becomes inconsistent
Database gets corrupted
Data lost due to system failures and natural disasters
Backup and Recovery in SQL
Server 2000
Lesson 2A / Slide 32 of 34
Administering and Troubleshooting SQL Server 2000
2A.64
Backup and Recovery in SQL Server 2000
Summary (Contd.)
©NIIT
2A.65
•
SQL Server uses the following Recovery models to recover the backed
up databases:
• Full Recovery Model
• Bulk Logged Recovery Model
• Simple Recovery Model
•
The following are the two types of recovery processes:
• Automatic recovery process
• Manual recovery process
Backup and Recovery in SQL
Server 2000
Lesson 2A / Slide 33 of 34
Administering and Troubleshooting SQL Server 2000
Backup and Recovery in SQL Server 2000
Summary (Contd.)
•
The following are the options of manual recovery process:
• Restoring database
• Restoring filegroups
• Restoring point-in-time
•
The restoration options are performed using:
• SQL Server 2000 Enterprise Manager
• Transact-SQL
•
You can also restore the master databases of SQL Server 2000.
©NIIT
Backup and Recovery in SQL
Server 2000
Lesson 2A / Slide 34 of 34
In this lesson, you have learned that:
Backup operations are performed to prevent data loss due to the following
reasons:
x Hardware failure
x Natural disaster
x Accidental or intentional damage to data
The following are the two types of backup devices:
x Disk backup device
x Tape backup device
The following can be used to create a backup device:
x SQL Server 2000 Enterprise Manager
x Transact-SQL
The types of backup operations are:
x
x
x
Full backup
Differential backup
Transaction log backup
Administering and Troubleshooting SQL Server 2000
2A.66
x Filegroup backup
x Differential filegroup backup
x Parallel striped backup
A full database backup refers to the backup of the entire SQL Server 2000
database.
Differential backup records and stores all the changes made to a database and
database objects since the last full backup of the database.
Filegroup backup makes copies of specific data files or the data files contained in
a single filegroup.
Differential filegroup backup refers to the backup of all the changes made to a
filegroup since the last filegroup backup.
Transaction log backup is a sequential record of the information stored in a
transaction log file.
Parallel striped backup is used to speed up the backup operation. In this type of
backup, you use multiple backup devices to backup multiple data files,
filegroups, and transaction log files.
The following are the alternative methods of performing different types of
backup operations:
x Transact-SQL
x The Tools menu of SQL Server 2000
Precautions for performing backups:
x
Enterprise Manager
You should not create or update a database using either the SQL Server
Enterprise Manager or the CREATE DATABASE statement.
x You should not increase or decrease the size of the database.
x You should not create indexes during a backup operation.
Recovery operations are performed to recover data lost from a database under
the following circumstances:
x After a backup operation has been performed on a database.
x Database becomes inconsistent.
x Database gets corrupted.
x Data lost due to system failures and natural disasters.
SQL Server uses the following Recovery models to recover the backed up
databases:
x
x
2A.67
Full Recovery Model
Bulk Logged Recovery Model
Administering and Troubleshooting SQL Server 2000
x Simple Recovery Model
The following are the two types of recovery
processes:
x Automatic recovery process
x Manual recovery process
The following are the options of manual recovery process:
x Restoring database
x Restoring filegroups
x Restoring point-in-time
The restoration options are performed using:
x SQL Server 2000 Enterprise Manager
x Transact-SQL
You can also restore the master databases of SQL Server 2000.
Administering and Troubleshooting SQL Server 2000
2A.68
[...]... 2A.27 Administering and Troubleshooting SQL Server 2000 PERFORMING BACKUPS USING ALTERNATE METHODS Backup and Recovery in SQL Server 2000 Other Ways to perform Backup ©NIIT • You can perform backup in other ways: • Using Tools menu of SQL Server 2000 Enterprise Manager • Transact -SQL • SQL Server 2000 enables you to perform the following types of backups using Transact -SQL: • Full database backup •... database backup • Filegroup backup Backup and Recovery in SQL Server 2000 Lesson 2A / Slide 15 of 34 Administering and Troubleshooting SQL Server 2000 2A.28 Backup and Recovery in SQL Server 2000 Other Ways to perform Backup (Contd.) • • • • You can perform a full database backup of the SQL Server 2000 database BACKUP DATABASE TO = You can use BACKUP DATABASE... the Backup Device Properties-New Device dialog box 8 Verify that the details pane of the SQL Server Enterprise Manager displays the newly created backup device Administering and Troubleshooting SQL Server 2000 2A.12 Creating a Permanent Backup Device Using Transact -SQL Backup and Recovery in SQL Server 2000 Creating a Permanent Backup Device using Transact -SQL • You can also create a permanent backup. .. The backup plan includes a schedule for performing the backup on every Sunday at 12:00 AM Administering and Troubleshooting SQL Server 2000 2A.18 Solution Backup and Recovery in SQL Server 2000 Task List • • • • ©NIIT Start the Database Backup Wizard Select the type of backup to be performed Select the backup device to be used Verify the backup operation Backup and Recovery in SQL Server 2000 Lesson... the Transact -SQL BACKUP LOG TO ©NIIT Backup and Recovery in SQL Server 2000 Lesson 2A / Slide 16 of 34 You can also perform backup by: Using Tools menu of SQL Server 2000 Enterprise Manager Using Transact -SQL Using Tools Menu of SQL Server 2000 Enterprise Manager To take backups using SQL Server 2000 Enterprise Manager, perform the following steps:... the name of the backup device, and is used by the operating system The physical_name refers to the physical name of the backup device and is used by the database administrator or the user 2A.13 Administering and Troubleshooting SQL Server 2000 Backup devices are not associated with a specific database Identifying the Types of Backups Backup and Recovery in SQL Server 2000 Types of Backups • • • •... USING THE DATABASE BACKUP WIZARD Backup and Recovery in SQL Server 2000 Performing Database Backup Using the Database Backup Wizard According to the security policy of Mac Aluminium, Inc., the administration department has been asked to design a backup plan The backup plan will use the Database Wizard of SQL Server 2000 Enterprise Manager for taking a full backup of the Master database and name the media... device, and backup as Mac The new full backup should be appended to the existing backup in the disk, Mac, and should be verified after the backup operation is complete The backup plan includes a schedule for performing the backup on every Sunday at 12:00 AM ©NIIT Backup and Recovery in SQL Server 2000 Lesson 2A / Slide 13 of 34 Problem Statement According to the security policy of Mac Aluminium, Inc.,... explaining the Transact -SQL method to perform backup operations, explain the syntax of the Transact -SQL statements with examples After discussing the various methods of performing different types of backup operations, tell the students about the precautions that should be undertaken while performing a backup operation 2A.17 Administering and Troubleshooting SQL Server 2000 PERFORMING DATABASE BACKUP USING... striped ©NIIT Backup and Recovery in SQL Server 2000 Lesson 2A / Slide 12 of 34 SQL Server 2000 provides various methods to back up databases, filegroups, and transaction log files The different backup methods of SQL Server are: Full Differential Filegroup Differential filegroup Transaction log Parallel striped Administering and Troubleshooting SQL Server 2000 2A.14 Full Backup Full backup refers
Ngày đăng: 16/10/2015, 21:33
Xem thêm: Backup And Recovery In SQL Server, Backup And Recovery In SQL Server