Sure, below is the code,
DECLARE @exitcode int
DECLARE @sqlerrorcode int
EXECUTE master..sqlbackup '-SQL "BACKUP DATABASES [DB1,DB2,DB3] TO DISK = ''C:\Backup\Full\<database>\<AUTO>.sqb'' WITH ERASEFILES_ATSTART = 1b, PASSWORD = ''<ENCRYPTEDPASSWORD>xxxxxxxxxxx</ENCRYPTEDPASSWORD>'', CHECKSUM, DISKRETRYINTERVAL = 30, DISKRETRYCOUNT = 10, KEYSIZE = 256, THREADCOUNT = 23"', @exitcode OUT, @sqlerrorcode OUT
IF (@exitcode >= 500) OR (@sqlerrorcode <> 0)
BEGIN
RAISERROR ('SQL Backup failed with exit code: %d SQL error code: %d', 16, 1, @exitcode, @sqlerrorcode)
END
I also double checked and no tape backups are running or did run at the same time.
DECLARE @exitcode int
DECLARE @sqlerrorcode int
EXECUTE master..sqlbackup '-SQL "BACKUP DATABASES [DB1,DB2,DB3] TO DISK = ''C:\Backup\Full\<database>\<AUTO>.sqb'' WITH ERASEFILES_ATSTART = 1b, PASSWORD = ''<ENCRYPTEDPASSWORD>xxxxxxxxxxx</ENCRYPTEDPASSWORD>'', CHECKSUM, DISKRETRYINTERVAL = 30, DISKRETRYCOUNT = 10, KEYSIZE = 256, THREADCOUNT = 23"', @exitcode OUT, @sqlerrorcode OUT
IF (@exitcode >= 500) OR (@sqlerrorcode <> 0)
BEGIN
RAISERROR ('SQL Backup failed with exit code: %d SQL error code: %d', 16, 1, @exitcode, @sqlerrorcode)
END
I also double checked and no tape backups are running or did run at the same time.