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 @   一只竹节虫  阅读(108)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
历史上的今天:
2021-01-11 oracle存储过程通过游标输出Sql结果集
点击右上角即可分享
微信分享提示