Backing up network databases, Backup method, N on the online backup feature, see backing – Echelon LNS User Manual

Page 265

Advertising
background image

LNS Programmer's Guide

251

Backing Up Network Databases

The ability to backup and restore an LNS database is a critical requirement for most

systems. LNS provides a network recovery feature you can use to recover a lost database

from the network, which is described later in this chapter. However, it is much more

reliable to use an archived copy to restore a lost database, or a database that has become
corrupted. Different factors can cause database corruption. For example, some hard disk

controllers have a write-caching option to improve write performance. Use of this option

is not recommended with database management software such as LNS, because a power
failure during operation may result in database corruption. You should note that most

Windows operating systems enable write-caching by default.

As described earlier in this chapter, the LNS Object Server maintains a network

database for each network defined in the global database. The location of the global
database is defined by the DatabasePath of the ObjectServer object, and is set to the
L

ON

W

ORKS

\ObjectServer\GlobalDb directory by default. The location of each network

database is defined when each network is created, and you can determine this location
later by reading the DatabasePath property of the Network object.

To backup a global database or a network database, copy the entire contents of the global

or network database directory, including all subdirectories. You can reduce the size of the

backup by using an archiving utility such as PKZIP to compress and archive the files. Be
sure to specify the appropriate options to include subdirectories in the archive.

You can restore both the global and network databases, or just the network database.

You can also restore databases to the same PC or a different PC. If you restore both

databases, the global database must be restored to the PCs default global database

directory, and each network database must be restored to its original location as defined
in the global database. Note that if you move an LNS database from one PC to another,

there are other files you will need to move as well. For more information on this, see

Moving Network Databases on page 256.

If you are restoring an existing network database, you should first delete any existing

files in the database folder and sub-folders, and then copy the backup files into the folder.

Make sure the network is closed when you do so. This will avoid leaving any

“stale” files in the restored database directory. If you are restoring a network
database that is not already on the PC, but is already referenced in the global database,

restore it to its original location. To restore a network database that is not already in the
global database, restore the database into a new directory, then call the Add() method
on the Networks collection with the CreateDatabase parameter set to False. This

tells the LNS Object Server that this is an existing database that must be registered in
the global database. Networks can only be imported by local applications. The following
code imports a network named "N1" with database path "c:\N1".
Dim MyNetwork as LcaNetwork

Set MyNetwork = MyNetworks.Add("N1", "c:\N1", False)

Backup Method

To facilitate the process of backing up your network databases, the Backup() method

has been added to the Network object for Turbo Edition. You can call this method on any

local network to make a backup copy of the network database, and export the backup

copy to a local directory of your choice. The following code sample backs up a network
database to the C:\BackupDBs\LNSNetworkDatabase folder.

Advertising