Apama 10.3.1 | Apama Documentation | Developing Apama Applications | Developing Apama Applications in EPL | Using Correlator Persistence | Backing up the persistence database while the correlator is running
 
Backing up the persistence database while the correlator is running
Backing up the correlator persistence database while the correlator is running is not as simple as copying the file. This is because copying files happens by reading chunks of the file at a time and copying them elsewhere. In between reading chunks of the file, it is possible that the database is modified. Because of this, it is required to make an atomic snapshot of the database file, reading the entire state in one go. This can be done using file-system snapshots, a capability provided by many storage systems (for example, VMWare or NetApp) or operating systems (for example, Shadow Copy on Windows, or LVM with XFS and Ext4 file systems on Linux).
Proceed as follows to create a backup of the persistence database:
1. Create a snapshot of the volume containing the persistence database file.
2. Copy the persistence database from the snapshot.
3. Also copy all other files with similar names in the same folder. Using a wildcard filter such as "persistence.db*" will copy the following:
*persistence.db
*persistence.db-journal
*persistence.db-wal
*persistence.db-shm
4. Delete the snapshot when you have copied all required files. The snapshot is no longer needed.
Examples of how to create a snapshot and back up the persistence database on Windows and Linux are given below.
Backing up the persistence database using Shadow Copy on Windows
On Windows server platforms, you can create a persistent snapshot of the volume containing the persistence database, copy the database and related files from the snapshot, and then delete the snapshot.
It is also possible to use a temporary snapshot to copy the files in a single command. This works on all supported Windows operating systems. For example, you can take a snapshot using the VShadow tool. With this tool, snapshots are temporary by default. To invoke the tool, use an elevated command prompt (that is, run the Windows command prompt as an administrator) and enter the following:
vshadow -nw -script=SETVAR1.cmd -exec=copyPersistence.bat D:
where:
*-nw makes the backup faster by skipping applications that react to a snapshot being taken, which the database does not.
*-script generates a script called SETVAR1.cmd which provides variables for accessing the snapshot.
*-exec runs the script copyPersistence.bat (see below) before the tool exits (that is, while the snapshot still exists).
*The final argument is the drive that contains the persistence database.
The copyPersistence.bat script handles the actual copying. It has the following content:
call SETVAR1.cmd
for %%i in (%SHADOW_DEVICE_1%\path\to\persistenceDatabase\persistence.db*)
do copy %%i D:\backup\location
Backing up the persistence database using LVM on Linux
Proceed as follows:
1. Log in as root.
2. Create a snapshot of the volume containing the persistence database:
lvcreate -L1G -s -n snapshot /dev/vgname/persistence_volume
In this case, the name of the snapshot is "snapshot".
Note: Some file systems require you to pause writes while creating the snapshot. On XFS, for example, you have to run xfs_freeze -f /myxfs before running lvcreate and then xfs_freeze -u /myxfs after it completes.
3. To copy the database, first mount the snapshot:
mount /dev/vgname/snapshot /mnt
4. Copy the relevant files from the snapshot:
cp /mnt/path/to/persistenceDatabase/persistence.db* /backup/
5. Unmount the snapshot:
umount /mnt
6. Remove the snapshot:
lvremove snapshot

Copyright © 2013-2019 | Software AG, Darmstadt, Germany and/or Software AG USA, Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors.