知識庫

Using DB EVENTS to backup a database server

Hint Ref: 020706290005
Hint Date: 29/06/2007

Hint Details:
EFFECTED VERSION: Sybase 8

 

DETAILS:

Modify the follow SQL to correct the backup time and target directory. Then run in an SQL window:

NOTE: The backup will only run if the database name, set up in the serve with '-n', is 'Spaceman'. If this is not the correct database name, change it here.  This is to ensure that a demo copy of the database does not cause the live backup to be overwritten by the event running from the demo database.


CREATE EVENT SMDailyBackup
SCHEDULE daily_backup
START TIME '7:00AM' EVERY 24 HOURS
HANDLER
  BEGIN
   if db_name='Spaceman' then begin
     BACKUP DATABASE 
     DIRECTORY 'L:\\dbbackup\\NickyDemo' 
     TRANSACTION LOG TRUNCATE
      end;
     end if;
    END


(L:\SM4WIN\SQL_Events\daily backup.txt)