Posted on Leave a comment

Scripted Backups Example 2

USE master
GO

DECLARE @theday char(1)
, @file varchar(128)

SET @theday = datepart(dw, getdate())

ALTER DATABASE dbname SET RECOVERY SIMPLE;

SET @file = 'D:BACKUPSdbname_' + @theday + '.bak';

BACKUP DATABASE dbname TO DISK = @file WITH INIT;

BACKUP LOG dbname WITH TRUNCATE_ONLY;

GO


This does a 7 day "rolling backup", overwriting the backup from last week. Set it up on a nightly job.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.