External Database Maintenance
315
n
ov
do
cx (e
n)
16
Ap
ril 20
10
Examples:
To back up the database at a 1:00 a.m. every day to the
/var/
directory on Linux, execute
the following query:
CREATE EVENT ZENDBbackup
SCHEDULE
START TIME '1:00 AM' EVERY 24 HOURS
HANDLER
BEGIN
BACKUP DATABASE DIRECTORY ‘/var/’
TRANSACTION LOG TRUNCATE
END;
To back up the database at a 1:00 a.m. on the first, second, third, and fourth day of the
month to the
c:\dbbackup
directory on Windows, execute the following query:
CREATE EVENT ZENDBbackup
SCHEDULE
START TIME '1:00 AM' EVERY 24 HOURS ON (1,2,3,4)
HANDLER
BEGIN
BACKUP DATABASE DIRECTORY ‘c:\\dbbackup’
TRANSACTION LOG TRUNCATE
END;
To back up the database to the
/var/
day_of_the_week
directory on Linux, execute the
following query:
CREATE EVENT ZENDBbackup
SCHEDULE
START TIME '1:00 AM' EVERY 24 HOURS
HANDLER
BEGIN
DECLARE backupDir varchar(256);
DECLARE backup_stmt varchar(512);
SET backupDir = DAYNAME(now());
SET backup_stmt = 'BACKUP DATABASE DIRECTORY '|| '''/var//' ||
backupDir || ''''|| ' TRANSACTION LOG TRUNCATE';
EXECUTE IMMEDIATE backup_stmt;
END;
According to the backup schedule, the
zenworks_
zone_name
.db
database file and the
zenworks_
zone_name
.log
transaction log file are created in the database backup directory.
If you want to change the database backup location or the backup schedule at a later time, see
Section 36.2.2, “Changing the Backup Schedule and Location of the External Sybase Database
Subsequent to the Initial Backup,” on page 335
.