SQL Anywhere 16, which is installed with SAP Mobile Platform, provides a function for automatically backing up databases on a weekly, daily, or hourly basis.
For more information about automatic backup options using schedules and events, see the SQL Anywhere documentation.
This example schedules an event in the target database to execute a full backup every two days, starting at 1:00AM.
CREATE EVENT WeeklyFullBackup SCHEDULE START TIME '01:00' EVERY 48 hours HANDLER BEGIN DECLARE dest LONG VARCHAR; DECLARE day_name CHAR(20); SET day_name = DATENAME( WEEKDAY, CURRENT DATE ); SET dest = 'c:\\HA_DR\\dailybackup\\clusterdb ' || day_name; BACKUP DATABASE DIRECTORY dest DBFILE ONLY; END;
The backup destination is c:\\HA_DR\\dailybackup\\clusterdb <day_name>, where <day_name> represents the day of the week, such as Monday, or Tuesday.
To run the event automatically, save each event script as a SQL file and execute it with the dbisqlc or dbisql command.
dbisqlc -c connstring c:\WeeklyFullBackup.sql
Alter event WeeklyFullBackup enable | disable;