Solved

Log Backup Fails

Posted on 2010-11-23
4
426 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 143

Expert Comment

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

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

Expert Comment

by:anushahanna
ID: 34199445
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
ID: 34201154
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
ID: 34210447

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

731 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