External Database Maintenance
321
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
/root/zenworks_dbbackup
directory on Linux, execute the following query:
CREATE EVENT ZENDBbackup
SCHEDULE
START TIME '1:00 AM' EVERY 24 HOURS
HANDLER
BEGIN
BACKUP DATABASE DIRECTORY ‘/root/zenworks_dbbackup/’
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
/root/zenworks_dbbackup
directory on Linux, 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 ‘/root/zenworks_dbbackup/’
TRANSACTION LOG TRUNCATE
END;
To back up the database to the
/root/zenworks_dbbackup/
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 '|| '''/root/
zenworks_dbbackup//' || backupDir || ''''|| ' TRANSACTION LOG
TRUNCATE';
EXECUTE IMMEDIATE backup_stmt;
END;
According to the backup schedule,
zenworks_
zone_name
.db
and
zenworks_
zone_name
.log
are
created in the network location on the remote machine (
/root/zenworks_dbbackup
). The backed-
up database is stored in
zenworks_
zone_name
.db
. The result of the database backup is logged in
zenworks_
zone_name
.log
.