星期三, 11月 24, 2021

[SQL] 備份成功紀錄

開啟 MS SQL 錯誤紀錄檔,會看到滿滿備份成功紀錄,錯誤紀錄檔案內重點,應該放在錯誤訊息的紀錄,因此透過 Trace flag 3226 關閉備份成功訊息紀錄,開啟後只會紀錄備份失敗訊息

[SQL] 備份成功紀錄-1

Trace flag 3226 說明
By default, every successful backup operation adds an entry in the SQL Server error log and in the system event log. If you create very frequent log backups, these success messages accumulate quickly, resulting in huge error logs in which finding other messages is problematic.

With this trace flag, you can suppress these log entries. This is useful if you are running frequent log backups and if none of your scripts depend on those entries.
在啟動參數內新增 3226,請輸入 [-T 3226]

[SQL] 備份成功紀錄-2

[SQL] 備份成功紀錄-3

最後可以透過 DBCC TracesStatus 來查詢 Trace Flags 的狀態,下列語法列出所有針對目前工作階段而啟用的 Trace Flags

沒有留言:

張貼留言