Performing backup and recovery for Oracle Database Lite is the same as what you would normally do for Oracle database applications. The following sections help you understand how to use the Oracle database backup and recovery methods for preserving your Mobile Server and Mobile applications:
Section 4.1, "How Does Oracle Database Lite Store its Information?"
Section 4.3, "Oracle Database Lite Backup Coordination Between Client and Server"
Oracle Database Lite uses the Oracle database to store information, as follows:
The Mobile Server itself is installed and configured as a database application. Thus, the Mobile Server stores its metadata and client state information within a database schema.
For each Mobile application, the Mobile Server installs triggers and stores transaction data in a schema for that application.
Since all of the data needed for a backup and recovery strategy exists in the database, you should use the Oracle database backup and recovery strategies discussed in the following books:
Oracle Backup Installation Guide
Oracle Database Recovery Manager Quick Start Guide
Oracle Database Backup and Recovery Basics
Oracle Backup Administrator's Guide
Oracle Database Backup and Recovery Advanced User's Guide
Note:
In the past, we recommended that you use export/import to perform a backup. This is not a recommended option anymore. Use the normal online Oracle database backup procedure.However, the following sections describe what to keep in mind when coming up with a backup and recovery strategy for your Oracle Database Lite environment: Section 4.3, "Oracle Database Lite Backup Coordination Between Client and Server" and Section 4.4, "Oracle Database Lite Recovery Issues".
When a client and a server synchronize with each other, the Mobile Server assigns the same "magic" number to both sides to indicate that the data is in-sync. If this number is different on both sides, the Mobile Server knows that the data is out of sync and is in an error condition. The following example details how this could effect your attempts for a clean recovery.
When you perform a backup, you may lose client data unless you plan accordingly. Figure 4-1 demonstrates the following scenario:
The client inserts record 1 and synchronizes the data to the server. The Mobile Server assigns the same magic number to both the client and the server to denote that they are in sync. In this example, the magic number on both the client and the server is 10.
The client inserts record 2. No synchronization is performed.
The backup is performed. Client record 1 is saved to the backup. The latest magic number on both the client and the server is 10.
The client inserts record 3 and synchronizes the data to the server. The Mobile Server assigns the same magic number to both the client and the server to denote that they are in sync. In this example, the magic number on both the client and the server is 20.
The client inserts record 4. No synchronization is performed.
A failure occurs and the last backup is used to recover the Mobile Server, the Mobile applications and the application data. In this scenario, only record 1 is in the backup, so it will exist in the restored database.
The client synchronizes. Records 2 and 3 can be lost, because they are not in the backup. The msync client does not send them to the server, since they were already sent in step 4. However, the msync client does send record 4 to the server, since it is a new record that has never been synchronized with the database. After the synchronization, record 4 is stored in the error queue, not in the application tables.
Figure 4-1 Lost Data With Backup and Recovery Strategy
The Mobile Server checks the magic numbers on both the client and the server. It verifies the state of the data on the client to determine what action to take. When the client performs the next synchronization, if the magic numbers are not the same, then the following occurs:
The client checks if there are any new records—whether newly inserted, modified, or deleted—on the client. If so, then these records are sent to the server, which saves these records in the error queue.
A full refresh of all of the subscribed data is sent to the client.
In our example, if you did nothing, the client would send record 4 to the server, which would end up in the error queue, and records 2 and 3 would be lost. To save records 2 and 3, do the following:.
On the server, retrieve and restore the last backup.
On the Mobile client that is out of sync, update any record that has been modified since the last synchronization. In our example, you would do any sort of update that makes the record seem to contain new information in records 2 and 3. For example, you could update the VARCHAR
field with the same content.
Initiate a synchronization on the client. The Oracle Database Lite software detects that the client database is out of sync and that some of the records have been modified. Thus, the following occurs:
The modified records are updated in the restored database on the server and saved in the error queue.
The server pushes a full refresh down to the client.
In order for you to reapply the modified records to the applications table, you must first modify the DML operation from Error to Update. The DBA must modify the record in the error queue for the base table, named CEQ$<base_table_name>
, changing the DML operation from Error (E
) to Update (U
) or Insert (I
).
Once updated to Update, re-execute the command. Navigate to the Error Queue screen in the Mobile Manager. Click on the modified record. Click Execute.
Note:
For more information on the error queue and how to reapply the records, see Section 3.11.1 "Resolving Conflicts Using the Error Queue" in the Oracle Database Lite Developer's Guide.The next time that the MGP runs, the update is applied to the application table.
Thus, all information contained within records 2 and 3 will be restored from the device.
When you perform a recovery, the state of both the Mobile Server and the Mobile application schemas must be in-sync. If they are out-of-sync, severe problems may occur. Therefore, when you perform a backup and restoration for the Mobile Server and the Mobile application schemas, each must be recovered to the same point in time. Use the Oracle database Point-in-Time Recovery strategy to ensure that both the Mobile Server schema and Mobile application schemas are recovered to the same point in time.
The Mobile application schemas usually reside on the same Oracle database instance as the Mobile Server. However, if you have used a database link to store the Mobile application schemas on a separate Oracle database instance, then you must use a backup and restore strategy for distributed database systems.