SQL Backup return code
Dje
Posts: 13
Hi,
I've got a question about how SQL Backup handles the retries.
I've got this piece of code :
where @err is the @return of the following backup line:
I'd like to know, in the case of a retry, how SQL Backup works.
I can notice in the log generated a return code of 300.
Is SQL Backup directly returning 300 and then the next return code ?
Will my stored procedure get the 300 before the retry succeed - and so continue without a successfull backup done ?
How to adapt the sp to wait until it succeeded or really fails ?
How to get the second/third... return code ?
Regards,
Jerome
I've got a question about how SQL Backup handles the retries.
I've got this piece of code :
exec SYS_BackupDatabaseFull @name, @err output, @backupType -- Check if the backup succeeded if (@err <> 0 and @err <>300) begin insert into failedBackup (name) values (@name + ' (Full)') insert into SYS_backup_log (dbName, action) values (@name, 'Full backup failed') set @failureOccur = 1 end
where @err is the @return of the following backup line:
SET @CommandString = '-SQL "BACKUP DATABASE [' + @DBName + '] TO DISK = ''' + @pathBackup + '\<DATABASE>\<AUTO>'' WITH DESCRIPTION = ''<AUTO>'', ERASEFILES_ATSTART = ' + @nbDayToKeepBackup + ', COMPRESSION = ' + @compression + ' , THREADCOUNT = ' + @threadcount + ' , LOGTO = [' + @logFolder + '\<database>_<datetime yyyymmdd_hhnnss>.log]"' EXEC master..sqlbackup @CommandString, @return output, @sqlerrorcode output
I'd like to know, in the case of a retry, how SQL Backup works.
I can notice in the log generated a return code of 300.
Is SQL Backup directly returning 300 and then the next return code ?
Will my stored procedure get the 300 before the retry succeed - and so continue without a successfull backup done ?
How to adapt the sp to wait until it succeeded or really fails ?
How to get the second/third... return code ?
Regards,
Jerome
Comments
In the case of retries, if the backup succeeded on subsequent attempt(s), there are no errors, so SQL Backup returns warning code 300. If none of the reattempts succeeded, an error code will be returned, as that is more 'serious' than a warning code.
There is only one return code returned for each SQL Backup task.
SQL Backup Consultant Developer
Associate, Yohz Software
Beyond compression - SQL Backup goodies under the hood, updated for version 8