You can create a logical backup device that points to
a physical backup device, which enables you to back up and restore
using the logical name instead of the actual physical device. This is
useful for providing an abstraction layer between backup scripts and the
actual physical backup devices. For example, if you need to change the
location for your backups, instead of changing every script, all you
need to do is delete the old logical backup device and create a new one
that points to the appropriate location.
To create a logical backup device, you can use the sp_addumpdevice system stored procedure. The code in Listing 1 creates a logical backup device named AdventureWorks BackupDevice
that points to the physical backup device
C:\Backup\AdventureWorks2008.bak. To drop a logical backup device, you
can execute the sp_dropdevice system stored procedure followed by the name of the device (also shown in Listing 1).
Example 1. Code to Add and Remove a Logical Backup Device Using T-SQL
USE master GO --Add logical backup device EXEC sp_addumpdevice @devtype ='disk', @logicalname ='AdventureWorksBackupDevice' , @physicalname ='C:\Backup\AdventureWorks2008.bak' GO
--Remove logical backup device EXEC sp_dropdevice 'AdventureWorksBackupDevice' GO
|
You can also add a
logical backup device using the SQL Server Management Studio GUI. Expand
the Server Objects node in the Object Explorer, right-click on the
Backup Devices folder, and select New Backup Device from the context
menu. This will bring you to the Backup Device dialog box, as shown in Figure 1. Enter the logical device name, device type, and physical location, and then select OK to create the device.
Once you create the backup
device, the next time you open the Backup Device dialog box, you will
see a Media Contents page. You can open the Backup Device dialog box
again by double-clicking the appropriate device in the Backup Devices
folder. The Media Contents page displays all of the backup sets that are
contained in the logical backup device, as shown in Figure 2. We have taken two full backups before opening the dialog box again for demonstration purposes.
You can query the sys.backup_devices catalog view to display a list all of the current logical backup devices, along with the physical device type and location. Figure 3 shows the results for the backup device we created in this section.