A
backup device is used to provide a storage destination for the database
backups created with SQL Server. Backups can be written to logical or
physical devices. A logical device is essentially an alias to the
physical device and makes it easier to refer to the device when performing
database backups. The physical backup devices that SQL Server can write
to include files on local disks, tape, and network shares.
Disk Devices
A disk device is generally
stored in a folder on a local hard drive. This should not be the same
hard drive where your data is stored! Disk devices have several
advantages, including speed and reliability. If you have ever had a
backup fail because you forgot to load a tape, you can appreciate the
advantage of disk backups. On the other hand, if backups are stored on a
local disk and the server is destroyed, you lose your backups as well.
Note
Disks have become
increasingly popular media as the prices have fallen. Storage area
networks (SANs) and other large-scale disk solutions have entered
mainstream usage and offer a large amount of storage at a relatively
inexpensive price. They also offer redundancy and provide fault
tolerance to mitigate the chance of losing data on a disk. Finally,
increased network bandwidth across LANs and WANs has allowed for the
movement of backups created on disk to alternate locations. This is a
simple way to achieve additional fault tolerance.
Tape Devices
Tape devices are used to back
up to tape. Tape devices must be directly connected to the server, and
parallel backups to multiple drives are supported to increase
throughput. Tape backups have the advantage of being scalable, portable,
and secure. Scalability is important as a database grows; available
disk space often precludes the use of disk backups for large databases.
Because tapes are removable media, they can easily be transported
offsite, where they can be secured against theft and damage.
SQL Server supports the
Microsoft Tape Format (MTF) for backup devices, which means that SQL
Server backups and operating system backups can share the same tape.
This capability is convenient for small sites with shared use servers
and only one tape drive. You can schedule your SQL Server backups and
file backups without having to be onsite to change the tape.
Network Shares
SQL Server 2008 allows the
use of both mapped network drives and Universal Naming Convention (UNC)
paths in the backup device filename. A mapped network drive must be
mapped as a network drive in the session in which SQL Server is running.
This is prone to error and generally not recommended. UNC paths are
much simpler to administer. With UNC backup devices, the SQL Server
service account must be able to see the UNC path on the network. This is
accomplished by granting the service account full control permission on
the share or by making the service account a member of the Administrators group on the remote computer.
Keep in mind that
backups performed on a network share should be done on a dedicated or
high-speed network connection, and the backup should be verified to
avoid potential corruption
introduced by network error. The time it takes a backup to complete
over the network depends on network traffic, so you need to take this
factor into consideration when planning your backups.
Media Sets and Families
When you’re backing up to multiple devices, the terms media set and media family are used to describe the components of the backup. A media set
is the target destination of the database backup and comprises several
individual media. All media in a media set must be of the same type (for
example, all tape or all disk). A media family
is the collection of media associated with an individual backup device.
For example, a media family could be a collection of five tapes
contained in a single tape device.
The first tape in the media family is referred to as the initial media, and the subsequent tapes are referred to as continuation media. All the media families combined are referred to as the media set.
If, for example, a backup is written to 3 backup devices (each with 4
tapes), the media set would contain 3 media families and consist of a
total of 12 tapes. It is recommended to use the MEDIANAME parameter of the BACKUP command to specify a name for the media set. This parameter associates the multiple devices as members of the media set. The MEDIANAME parameter can then be referenced in future backup operations.
Creating Backup Devices
You can create logical backup devices by using T-SQL or SSMS. The T-SQL command for creating these logical backup devices is sp_addumpdevice, which has the following syntax:
sp_addumpdevice [ @devtype = ] 'device_type'
, [ @logicalname = ] 'logical_name'
, [ @physicalname = ] 'physical_name'
[ , { [ @cntrltype = ] controller_type |
[ @devstatus = ] 'device_status' }
]
The following sample script demonstrates the creation of the different types of backup devices:
-- Local Disk
EXEC sp_addumpdevice 'disk', 'diskdev1',
'c:\mssql2008\backup\AdventureWorks2008.bak'
-- Network Disk
EXEC sp_addumpdevice 'disk', 'networkdev1',
'\\myserver\myshare\AdventureWorks2008.bak'
-- Tape
EXEC sp_addumpdevice 'tape', 'tapedev1', '\\.\tape0'
To create backup devices with SSMS, you navigate to the Server Objects node in the Object Explorer and right-click Backup Devices and then New Backup Device; the Backup Device
screen appears. This screen includes a text box for the device name,
along with a section to select the destination for the device. This is
the physical location, and you can select either Tape or File.