Log Chains

I am using the following the code to back up my log file:

backup log blackiceproject to disk
= 'C:\Black Ice Project Log\logbackup.bak';
Over time (the back up job runs every 15 mins)I was expecting to see a number of different files in the "C:\Black Ice Project Log" however I only see the one back up file. Can you please help me by telling me how I can generate a log chain. Thank you
more ▼

asked Aug 17, 2010 at 06:22 PM in Default

Mr Q gravatar image

Mr Q
11 1 1 1

(comments are locked)
10|1200 characters needed characters left

1 answer: sort voted first

The script does exactly what you ask, and thus, it always overwrites existing file because the script always provides same path. The simplest thing to do would be to add the date and time part to the file name, for example:

declare @path nvarchar(255);
set @path = 
    N'C:\Black Ice Project Log\logbackup_' +
    convert(nvarchar(8), getDate(), 112) + N'_' + 
    replace(convert(nvarchar(8), getDate(), 8), ':', '') + N'.bak';

backup log blackiceproject to disk = @path;
This will generate the log files like C:\Black Ice Project Log\logbackup_20100817_212509.bak
more ▼

answered Aug 17, 2010 at 07:29 PM

Oleg gravatar image

15.9k 2 4 24

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

New code box

There's a new way to format code on the site - the red speech bubble logo will automatically format T-SQL for you. The original code box is still there for XML, etc. More details here.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.



asked: Aug 17, 2010 at 06:22 PM

Seen: 809 times

Last Updated: Aug 17, 2010 at 07:11 PM