Solved

Log Backup Fails

Posted on 2010-11-23
4
421 Views
Last Modified: 2012-08-13
I have job which takes the T-log backups for every 15 Mins,but it is failing due to the below error.
Message
Executed as user: XXXXXXXXXXX. backup log db_name  to disk='p:\TruncateLog.trn' with init [SQLSTATE 01000]
 (Message 0)  The backup data in 'p:\TruncateLog.trn' is incorrectly formatted. Backups cannot be appended,
but existing backup sets may still be usable. [SQLSTATE 42000] (Error 3266)  BACKUP LOG is terminating abnormally.
[SQLSTATE 42000] (Error 3013).  The step failed.

I am running the below sql for the job,am i missing anything in the sql,if yes can someone correct it.

declare @sql varchar(500),@db varchar(60)
select @db=min(name) from master..sysdatabases where databasepropertyex(name,'Recovery')='FULL'
while @db is not null
begin
      set @sql='backup log '+@db+'  to disk=''p:\TruncateLog.trn'' with init'
      print @sql
      exec (@sql)
      select @db=min(name) from master..sysdatabases where databasepropertyex(name,'Recovery')='FULL' and name>@db
end

I am running on Microsoft SQL Server  2000 - 8.00.2040 (Intel X86) - SP4


Thanks,
K
0
Comment
Question by:Kodukulla
  • 2
4 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
http://support.microsoft.com/kb/290787

you will need to write to a new file ...
0
 
LVL 6

Expert Comment

by:anushahanna
Comment Utility
you want to make the INIT to NOINIT since you are dumping all the backups into the same file.
http://msdn.microsoft.com/en-us/library/ms186865.aspx

"Indicates that the backup set is appended to the specified media set, preserving existing backup sets. If a media password is defined for the media set, the password must be supplied. NOINIT is the default."
0
 

Author Comment

by:Kodukulla
Comment Utility
Hi,anushahanna

If i want to take the backups for all the databases individually ( Different trn dump files ) then.I still doubt something wrong with this statement.

set @sql='backup log '+@db+'  to disk=''p:\TruncateLog.trn'' with init'

How can i give the database name before the ( ""disk=''p:\TruncateLog.trn'' with init'"" ) P:\MyDB_Trncatelog.trn .

Please help.
0
 
LVL 6

Accepted Solution

by:
anushahanna earned 500 total points
Comment Utility

OK- please try any of these variations:

set @sql='backup log '+@db+'  to disk=''p:\'+ @db+'_'+replace(replace(cast(getdate() as varchar(100)),' ',''),':','')+'_TruncateLog.trn'' with init'
or
set @sql='backup log '+@db+'  to disk=''p:\'+ @db+'_TruncateLog.trn'' with init'
 
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now