• sharon (4/30/2008)


    mike please can you explain with examples to make it more clear

    Sharon,

    1) The Weekly Full Backup job, which runs Sundays at 7 pm, has the following steps:

    [font="Courier New"]backup database [MyDB] to [MyDB]

    with init, name=N'MyDB', description=N'Weekly Full'

    backup log [MyDB] to [MyDB_Log]

    with init, name=N'MyDB', description=N'Init'[/font]

    2) The Daily Differential Backup job, which runs Mon-Sat at 7 pm, has the following steps:

    [font="Courier New"]backup database [MyDB] to [MyDB]

    with differential, name=N'MyDB', description=N'Diff'

    backup log [MyDB] to [MyDB_Log]

    with init, name=N'MyDB', description=N'Init'[/font]

    3) The "hourly" log backup runs every 15 minutess from midnight to 6:45 pm, Sun - Sat, and includes the following step:

    [font="Courier New"]backup log [MyDB] to [MyDB_Log]

    with name=N'MyDB_Log', description=N'Hourly'[/font]

    The backup device can be created from the GUI, or with the following T-SQL:

    [font="Courier New"]declare @DB Nvarchar(50)

    declare @device Nvarchar(50)

    declare @BackupFolder nvarchar(255)

    declare @DeviceFile nvarchar(255)

    set @DB = N'DB_Name'

    set @BackupFolder = N'S:\SqlBackups\'

    set @device = @DB

    set @deviceFile = @BackupFolder + @device + '.Bak'

    exec sp_addumpdevice @devtype = 'disk', @logicalname = @device, @physicalname = @deviceFile

    set @device = @DB + N'_Log'

    set @deviceFile = @BackupFolder + @device + '.Bak'

    exec sp_addumpdevice @devtype = 'disk', @logicalname = @device, @physicalname = @deviceFile[/font]

    Change @DB and the path for @BackupFolder to whatever will work in your environment. Makes a device for both MyDB and MyDB_Log.

    For performance reasons, the backup works best if the destination is on separate media from the database files and logfiles. This is also desirable if your backup is to be used in case of a local drive failure.

    Mike Hinds Lead Database Administrator1st Source BankMCP, MCTS