|
Greetings, As a follow-up to my last post re: "Rebuilding backup script using set based logic…", my backup fails (both using the original cursor method and the new loop table var method) with a 3013 "BACKUP DATABASE is terminating abnormally." message. I've hacked away at this for a while, and am stumped as to why it's failing. Basically this is an archiving stored procedure. The tables are stored monthly, using the naming format: LogsYYYY_MM (example: Logs2009_10 for Oct 2009). After 13 months, the data is no longer required, so this stored proc copies the data to an empty "archiveLogs" database, backs it up, and then drops the table. The problem is with the backup, as stated above. I'm not sure why it fails. If I run the backup command "manually" it runs just fine and creates the backup file. Here's the code (including a lot of extra debug code for debugging): Note: the "top 500" filter on the data is just to speed up my debugging process. Normally that's not there, and it copies 6 or 7 million rows. CREATE PROCEDURE archiveLogs AS BEGIN SET NOCOUNT ON;
END GO Here's the debug log output: logDateTime logText ----------------------- ------------------------------------------------------------------------------------------------ 2009-10-13 14:17:15.333 archiveLogs: Starting. 2009-10-13 14:17:15.333 archiveLogs: Last month of logs to keep: Logs2008_09 2009-10-13 14:17:15.333 archiveLogs: Number of tables to archive: [7] 2009-10-13 14:17:15.333 archiveLogs: Archving data from Logs table: [Logs2008_02]... 2009-10-13 14:17:15.333 SELECT TOP 500 * INTO archiveLogs.dbo.Logs2008_02 FROM Logs2008_02 2009-10-13 14:17:15.663 archiveLogs: Rowcount: 500 records copied to archive table (archiveLogs.dbo.Logs2008_02). 2009-10-13 14:17:15.663 archiveLogs: Backing up archiveLogs.dbo.Logs2008_02 to LIVE_BACKEND_archiveLogs_Logs2008_02.bak 2009-10-13 14:17:15.663 archiveLogs: Backup Filename: [D:\DB Backups\LIVE_BACKEND_archiveLogs_Logs2008_02.bak] 2009-10-13 14:17:15.663 archiveLogs: Error Message: BACKUP DATABASE is terminating abnormally. 2009-10-13 14:17:15.663 archiveLogs: Error Message: 3013 2009-10-13 14:17:15.663 archiveLogs: Error during BACKUP. I don't know if there is some reason why it doesn't like running the backup command along with the dynamic SQL, or what the issue might be. I've trying running the backup command "dynamically" (as an EXEC stmt) as well, but that makes no difference (not a surprise). Thanks! Bill
(comments are locked)
|
|
I think it's probably time to break down your logic into smaller chunks to debug. I would probably start with a simple backup command and work backwards. Just from my outside observation it seems like you are knee-deep in sql code. Also, is there any reason for all the extra commands in the backup stmt? What about:
Here's a MS article on code 3013 Good Luck! Good point. I stripped it down to the basic backup command, which still failed, but at least this time it gave me more details. Namely, it was telling me a could not run the backup because I was inside a transaction. ARGH! I run my SQL query windows in IMPLICIT_TRANSACTIONS ON mode (I'm an Oracle guy, so I like issuing commit or rollback after I do stuff). The backup was failing because of this. Silly me. However, Silly SQL Server for not simply telling me this in the ERROR_MESSAGE() in the first place! Thanks everyone!
Oct 13 '09 at 05:24 PM
Bill
(comments are locked)
|
|
In your debugging, is the path and filename valid? Could this file already exist? In which case, a WITH INIT might help. I'm slightly confused as to what is broken. If you run the proc with just the backup, strip out all the table copy stuff, does that work? WITH INIT is already specified. Thanks for the tip though.
Oct 13 '09 at 05:21 PM
Bill
(comments are locked)
|

