Get IT Done: Back up and restore an NT4 DHCP infrastructure

Backing up and restoring a Windows NT4 DHCP infrastructure

Even as Windows NT is being phased out in favor of Windows 2000 (Win2K) and Windows 2003 (WS2K3) in many organizations, the need to properly maintain the services provided by these venerable servers will be there until they are replaced in large numbers—which hasn't completely happened yet.

A service that works very well under Windows NT and is widely used is the DHCP service. As you're probably well aware, DHCP is responsible for automatically configuring client workstations with network parameters, such as the IP address, subnet mask, DNS servers, WINS servers, NetBIOS node type, and much more.

Since the requirements for maintaining an NT4 DHCP service differ from Win2K and WS2K3, I'm going to provide you with some special guidance for NT4 DHCP servers.

The DHCP database keeps track of such items as which IP addresses have been assigned and when address leases are due to expire. By default, the Windows NT DHCP service backs up its database every hour. If this interval is not adequate for your needs, you can either change it or manually back up the database.

To change the DHCP database backup interval, start the registry editor and browse to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\ DHCPServer\Parameters and look for the BackupInterval key. To modify it, double-click it and change the interval to a value in minutes that you prefer. In Figure A below, the backup interval has been changed to 30 minutes.

Figure A
The DHCP database backup interval is modified in the registry.

Once you have changed the value for the backup interval, you need to restart the DHCP service. You can do this from Start | Settings | Control Panel | Services. From there, you can select DHCP Server and restart it.

Perform a manual backup
Even though the service backs up its own database every so often, you can manually back it up if the need arises. DHCP stores its database at %SystemRoot%\System32\dhcp\backup\Jet. To back up the database manually, simply stop the DHCP service and then copy this folder to another location. Once it is copied, you can restart DHCP.

Database maintenance
One instance where you may want to consider manually backing up the DHCP database is immediately before performing database maintenance. If, for some reason, your DHCP database is rather large, you may need to manually compact it.

To do this, you first need to stop the DHCP services at Start | Settings | Control Panel | Services, double-click DHCP Server, and then stop it. Next, from a command prompt, change to the \%systemroot%\system32\dhcp (the default is c:\winnt\system32\dhcp) directory. Next, type:
jetpack dhcp.mdb compress.mdb

This will compress the DHCP database into the compress.mdb file. You can then copy the compress.mdb file back over dhcp.mdb and delete compress.mdb. Restart the DHCP service when you are done.

Restoring the DHCP database
Like any database, there is always a chance that something will corrupt the DHCP database. DHCP actually keeps around two copies of the database. The first one is the backup that is performed automatically and the second is made up of the contents of the registry key, which also stores much of the DHCP information. In Windows NT 4, the backup of the DHCP database (dhcp.mdb) is stored in the %SystemRoot%\System32\dhcp\backup\Jet\New folder, while the file containing the registry information—Dhcpcfg—can be found in the %SystemRoot%\System32\dhcp\backup folder.

Let's look at how to restore a corrupted database. Remember that before you can correct a corrupted DHCP database, you will need to stop the DHCP service, if it is still running.

The first step in this process is to copy the corrupted file structure elsewhere. You never know when you might need to try to use it. To copy the most recent back up of the DHCP database over the corrupt one, type:
copy %SystemRoot%\system32\dhcp\backup\jet\new\dhcp.mdb %SystemRoot%\system32\dhcp\dhcp.mdb

If this file is also corrupt, you may need to restore the dhcp.mdb file from a recent backup.

Before restarting the service, you will need to compress the restored dhcp.mdb file using the instructions from the previous section of this article. If, after you compress the database, you are missing scope information, you will also need to restore the registry portion of the DHCP services.

To do this, start the registry editor and browse to HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\DHCPServer\Configuration. Make sure that you select the Configuration key. From the Registry menu, choose the Restore option. When prompted, use the file name %SystemRoot%\System32\dhcp\backup\Dhcpcfg and, when asked if you would like to restore over the existing key, choose Yes.

Whether you have scope configuration problems or not, you should also choose to synchronize the database with the registry. For each scope, double-click it to view the active leases. Click Reconcile to synchronize the database with the registry. If everything is as it should be, you will receive a dialog box indicating that the database is consistent, as shown in Figure B.

Figure B
This verifies reconciliation of the DHCP database and the registry.

With minimal maintenance, your Windows NT 4 DHCP services should keep running for a long time. For those times when you do encounter problems or wish to be more proactive in your administration habits, these tips can help you to back up, restore, and maintain your services.


Editor's Picks