Backup Devices

A backup device is a logical object that points to a physical backup destination (disk file, tape, or URL). Backup devices simplify backup and restore commands by allowing you to reference a name rather than a full path each time.

Types of Backup Devices

Creating a Backup Device

T‑SQL
  • PowerShell
  • USE master;
    GO
    EXEC sp_addumpdevice
        @devtype = N'disk',
        @logicalname = N'MyBackupDevice',
        @filename = N'C:\Backups\MyDatabase.bak';
    GO
    Add-SqlBackupDevice `
        -ServerInstance "MyServer" `
        -DeviceName "MyBackupDevice" `
        -Path "C:\Backups\MyDatabase.bak" `
        -BackupDeviceType "Disk"

    Backing Up Using a Device

    BACKUP DATABASE AdventureWorks
    TO MyBackupDevice
    WITH FORMAT, INIT, COMPRESSION;
    GO

    Restoring from a Device

    RESTORE DATABASE AdventureWorks
    FROM MyBackupDevice
    WITH MOVE 'AdventureWorks_Data' TO 'C:\Data\AdventureWorks.mdf',
         MOVE 'AdventureWorks_Log' TO 'C:\Data\AdventureWorks_log.ldf',
         RECOVERY;
    GO

    Related Topics