Sybase启用增量备份时如何预防数据库日志饱满

按照增量备份的逻辑,
1,数据库设置了自动清除日志,则不能做增量备份。
2,(关闭自动清除日志)手工清除日志后,需要一个新的全库备份后,才能开始新的增量备份。

数据库日志快满时,系统会触发一次last chance threshold,这个时候,会自动执行sp_thresholdaction存储过程。
sp_thresholdaction系统没有定义,用户可以根据自己的需求来书写sp_thresholdaction。

对应我们的应用,可以这样:
use HH_LC
go
create procedure sp_thresholdaction
@dbname varchar(30),
@segmentname varchar(30),
@space_left int,
@status int
as
dump transaction @dbname with truncate_only
go

还可以自己定义 user defined threshold,当日志剩余空间达到用户指定的值时,触发用户指定的存储过程。
定义user defined threshold后,相当于双保险,因为有些数据库可能由于某些原因(比如数据库建库混乱),系统的last chance threshold失效。

 

 

--user defined threshhold and action:
use HH_LC
go

sp_addthreshold "HH_LC", "logsegment", 50000, user_threshold_proc --日志空间剩余50000页时执行user_threshold_proc
go

create procedure user_threshold_proc
@dbname varchar(30),
@segmentname varchar(30),
@space_left int,
@status int
as
dump transaction @dbname with truncate_only
go

posted @ 2022-01-11 15:16  一只竹节虫  阅读(85)  评论(0编辑  收藏  举报