?
Solved

Log Backup Fails

Posted on 2010-11-23
4
Medium Priority
?
429 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 2000 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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

765 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