Sybase ASA數據庫自動備份的簡易實現
主要就是通過它的Event功能來實現,Event如同定時任務,到時間就觸發,觸發時你可以調用很多東西。 www.2cto.com
看看下邊兩個簡單示例:
看看下邊的兩個簡單的例子:
1. 從第一個磁帶開始自動備份,每天零晨1點開始自動執行。
Instruct the database server to carry out an automatic backup to tape using the first tape drive, every day at 1 A.M.
CREATE EVENT DailyBackup
SCHEDULE daily_backup
START TIME '1:00AM' EVERY 24 HOURS
HANDLER
BEGIN
BACKUP DATABASE TO '\\\\.\\tape0'
ATTENDED OFF
END;
2. 每天8點到下午6點,每個小時做一次事務日志的自動備份,備份到目錄c:\database\backup
Instruct the database server to carry out an automatic backup of the transaction log only, every hour, Monday to Friday between 8 A.M. and 6 P.M.
CREATE EVENT HourlyLogBackup
SCHEDULE hourly_log_backup
BETWEEN '8:00AM' AND '6:00PM'
EVERY 1 HOURS ON
('Monday','Tuesday','Wednesday','Thursday','Friday')
HANDLER
BEGIN
BACKUP DATABASE DIRECTORY 'c:\\database\\backup'
TRANSACTION LOG ONLY
TRANSACTION LOG RENAME
END;
這個功能,相比其它數據庫而言,真是非常強大而且方便。