By default, the following BizTalk jobs aren’t configured and enabled upon installation.
If you want these functionalities you must configure and enabled them.
This Job consists of four steps:
Step 1 – Set Compression Option
This job step calls a stored procedure named sp_SetBackupCompression on the BizTalk management database (BizTalkMgmtDb by default) to set the value on the adm_BackupSettings table.
The original script is:
exec [dbo].[sp_SetBackupCompression] @bCompression = 0 /*0 - Do not use Compression, 1 - Use Compression */
The stored procedure has only one parameter:
Change the script to:
exec [dbo].[sp_SetBackupCompression] @bCompression = 1 /*0 - Do not use Compression, 1 - Use Compression */
For more information see Tiago Almeida article: BizTalk Server 2010 Backup Compression
Step 2 – BackupFull
The original script is:
exec [dbo].[sp_BackupAllFull_Schedule] 'd' /* Frequency */, 'BTS' /* Name */, '<destination path>' /* location of backup files */
Where:
There are also three optional parameters:
Change the script to:
exec [dbo].[sp_BackupAllFull_Schedule] 'd' /* Frequency */, 'BTS' /* Name */, '<your_destination_path>\BizTalk Database\Full' /* location of backup files */
Step 3 – MarkAndBackUpLog
The MarkAndBackupLog step is responsible for marking the logs for backup, and then backing them up.
The original script is:
exec [dbo].[sp_MarkAll] 'BTS' /* Log mark name */, '<destination path>' /* location of backup files */
Where:
There is also one optional parameter:
exec [dbo].[sp_MarkAll] 'BTS' /* Log mark name */,'<destination path>' /*location of backup files */ , 1
Change the script to:
exec [dbo].[sp_MarkAll] 'BTS' /* Log mark name */, '< your_destination_path>\BizTalk Database\Logs' /* location of backup files */
Step 4 – Clear Backup History
The original script clear out the instances in the MarkLog table older than 14 days:
exec [dbo].[sp_MarkAll] 'BTS' /* Log mark name */, '< your_destination_path>\BizTalk Database\Logs' /* location of backup files */
Where:
There is also one optional parameter:
exec [dbo].[sp_DeleteBackupHistory] @DaysToKeep=14 , @UseLocalTime =1
In this particular case I like to leave the default settings.
Note:
This job step does not provide functionality for deleting backup files that have accumulated over time.
You can solve this problem by implementing you custom sp_DeleteBackupHistory:
CREATE PROCEDURE [dbo].[sp_DeleteBackupHistoryAndFiles] @DaysToKeep smallint = null
ASBEGIN
set nocount on
IF @DaysToKeep IS NULL OR @DaysToKeep <= 1
RETURN
/* Only delete full sets
If a set spans a day in such a way that some items fall into the deleted group and the other does not, do not delete the set */DECLARE DeleteBackupFiles CURSOR
FOR SELECT 'del "' + [BackupFileLocation] + '\' + [BackupFileName] + '"' FROM [adm_BackupHistory]
WHERE datediff(dd, [BackupDateTime], getdate()) >= @DaysToKeep
AND [BackupSetId] NOT IN (SELECT [BackupSetId] FROM [dbo].[adm_BackupHistory] [h2] WHERE [h2].[BackupSetId] = [BackupSetId] AND datediff(dd, [h2].[BackupDateTime], getdate()) < @DaysToKeep)DECLARE @cmd varchar(400)
OPEN DeleteBackupFiles
FETCH NEXT FROM DeleteBackupFiles INTO @cmd
WHILE (@@fetch_status <> -1)
BEGIN
IF (@@fetch_status <> -2)
BEGIN
EXEC master.dbo.xp_cmdshell @cmd, NO_OUTPUT
delete from [adm_BackupHistory] WHERE CURRENT OF DeleteBackupFiles
print @cmd
END
FETCH NEXT FROM DeleteBackupFiles INTO @cmd
ENDCLOSE DeleteBackupFiles
DEALLOCATE DeleteBackupFiles
END
GO
This job automates the archiving of tracked messages and the purging of the BizTalk Tracking database to maintain a healthy system and to keep the tracking data archived for future use.
And it’s configured to call the stored procedure dtasp_BackupAndPurgeTrackingDatabase, which uses the six parameters you must configure in this job:
The original script after installing BizTalk looks like this:
exec dtasp_BackupAndPurgeTrackingDatabase
0, --@nLiveHours tinyint, --Any completed instance older than the live hours +live days
1, --@nLiveDays tinyint = 0, --will be deleted along with all associated data
30, --@nHardDeleteDays tinyint = 0, --all data older than this will be deleted.
null, --@nvcFolder nvarchar(1024) = null, --folder for backup files
null, --@nvcValidatingServer sysname = null,
0 --@fForceBackup int = 0 --
This means that:
Normally I use these configurations for production environments:
exec dtasp_BackupAndPurgeTrackingDatabase 0, 10, 20, '<destination path>', null, 0
For more information: How to Configure the DTA Purge and Archive Job
However in a development machine we don’t need to maintain the archived tracking data, so I just purge it periodically. BizTalk gives you the option to Archive and Purge the tracking data or just simple purge the data without archiving:
declare @dtLastBackup datetime set @dtLastBackup = GetUTCDate() exec dtasp_PurgeTrackingDatabase 1, 0, 7, @dtLastBackup
Removes all messages that are not referenced by any subscribers in the BizTalkMsgBoxDb database tables.
Important:
This job is also started by theMessageBox_Message_ManageRefCountLog_BizTalkMsgBoxDb job. Therefore, we recommend that you disable this job.