Avatar of jim3725
jim3725
 asked on

dhcp backup restore netsh

A couple of things. I did a netsh dhcp show server and 4 servers were found in the directory services.
Only one server is the dhcp server, the other 3 do not exist any longer. their Directory service Ds location: cn=192.168.1.12 , etc. How do I remove those 3 bad entries?
Also I did a copy bat file in task scheduler to copy the contents from c:\windows\system32\dhcp\backup to another DC server to a mapped Z drive. This will run everyday at 6pm.
What is the process for restoring this dhcp db if my primary dhcp server fails.
both servers are virtual enterprise windows 2008 sp2 servers
Windows Server 2008

Avatar of undefined
Last Comment
jim3725

8/22/2022 - Mon
Mahesh

Logon to root Domain DC as member of domain admins \ enterprise admins ID and load configuration partition in Adsiedit.msc tool
The tool is available under Start\administrative tools
Then navigate to Configuration\services\Net Services
There you will find all authorized DHCP servers in active directory, just delete unwanted server from there and force AD replication
At same place above you will find DHCPRoot, go to its properties and navigate to DHCPServers attribute, double click it and ensure that there are no stale DHCP server entry left, if found, just delete it as well.
Again force AD replication.
This will remove unwanted DHCP servers from AD
http://blogs.technet.com/b/networking/archive/2009/02/27/old-dhcp-servers-appear-in-the-list-of-authorized-servers-after-a-domain-rename.aspx

The process of exporting DHCP scope from one server and importing it on another server is pretty straight forward. User netsh command for that, Check below article for step by step
http://support.microsoft.com/kb/281626
http://blogs.technet.com/b/canitpro/archive/2013/04/29/step-by-step-migration-of-dhcp-from-windows-server-2003-to-windows-server-2012.aspx

Mahesh
jim3725

ASKER
Mahesh,  I launched the adsiedit and i only see the default naming conxted for my domain , plus the CN= computers, CN=Bulletin, CN=Domain Controllers. I don't see where to  navigate to Configuration\services\Net Services
This is great info, but I need alittle more help.
jim3725

ASKER
Also, I am not able to located the export command within my DC1 server, so I can do the export
The following command exports the full service configuration to the c:\Temp\Dhcpdb file:
export c:\temp\dhcpdb all
Your help has saved me hundreds of hours of internet surfing.
fblack61
Mahesh

In adsiedit.msc right click adsiedit and click connect to
Under "Select well known naming context" radio button, from drop down list, select Configuration and click OK

For export and import, you need to 1st get into netsh prompt

Open elevated command prompt on DHCP server
Then type Netsh and hit enter
Then type Dhcp server \\DHCPServerName - logged on server
Then type export c:\temp\dhcpdb all
This will backup \ export DHCP server database.

Copy this DHCP server backup folder to new DHCP server where you want to restore Database
Now from elevated command prompt run Netsh and hit enter
Then type Dhcp server \\DHCPServerName - logged on server
Then type import c:\temp\dhcpdb all
This will restore \ import DHCP server database to new server

The both links shown in earlier already mentioned all these steps, you forgot to run netsh from elevated command prompt
jim3725

ASKER
Mahesh, I found the netservices. and deleted the entries. How do I force AD replication ?
I appreciate your explanations, they are very helpfull
jim3725

ASKER
Do I just go to Action and update schema now for AD replication?
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Mahesh

Logon to domain controller
From elevated command prompt run repadmin /syncall command
This command will force D replication
U may run this command on every domain controller OR AD replication will automatically takes place after 3 HRS
jim3725

ASKER
quick question: If on my other server that I would run the import command on, If the server does not have dhcp server activated, cause I don't want to activate , but will the import command work, if dhcp is not active?
Just wanted to ask.
Mahesh

Import will work, you can later authorize DHCP server

DHCP server service get stopped automatically before you import database
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
jim3725

ASKER
Mahesh, I added the dhcp server role on to my other dc.
I rebooted server. I am not able to unauthorize it when the service is started.  It's says parameter is incorrect when I try to unauthorize it. I currently have dhcp server service disabled. Not sure if if can do the import they way it stands now.
I'm hesitant on enabling this, I haven't added any scope parameters.  My goal was to have a 2nd dhcp ready incase their my primary dhcp server failed.
jim3725

ASKER
I got the following error message then trying to do import see attatchment.
Option 6 is dns entry, and 192.168.4.4 is the server that I 'm trying the import on.
Mahesh

If its already authorized, no need to unauthorized it.

The error message is came because existing DNS entry is got created under DHCP server options during your initial DHCP installation \ setup

Start the DHCP server service for time being and Go to server options on DHCP server snap-ins and remove the option 6 dns option

Then restore DHCP database (Import with Netsh) and check if everything is restored correctly, then stop and disable DHCP service and let me know if it works.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
jim3725

ASKER
mahesh, This worked sucessfully. Is it best to just do a manual export and import weekly to keep a current copy on the spare dhcp server?
jim3725

ASKER
Mahesh, I also validated that the spare server is an  authorized DHCP servers in active directory.
thanks again for your help
Mahesh

No need to import every week on spare DHCP server to make it current.

All you need to do is, just set some thing like .bat file to backup DHCP DB from Netsh export command and make it schedule task on primary server on daily or weekly basis.

Any time you wanted to bring spare server online, just ensure that this server goes offline and start dhcp service on spare server and import DHCP from backup above

Ex bat file

Netsh
Dhcp server \\DHCPServerName
export c:\temp\dhcpdb all

If you created this type of .bat script, its output will get overwritten every time by new output and you will get latest backup copy if required.

As additional measure you can backup this already backed up DB to another location if required
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
jim3725

ASKER
Mahesh, I tried this as a bat file, and It didn't overwrite it, Can you take a look at it.
the task history says task dhcp-export sucessfully completed cation "c:\windows\system32\cmd.exe" with return code 1.
I didn't see the date change on the c:\temp\dhcpdb file
C--download-dhcpcopy.txt
Mahesh

I think its refusing to overwrite

You can rename old dhcp db and check if new file gets created

In that case you can delete old file after backing it to else location
also copy command should be
copy c:\temp\* z:\
jim3725

ASKER
When I run this from command line, it works fine for exporting, it takes about 5-10 sec.
When I use the batch file it doesn't seem to wait long enough before it goes on to the next command for copying, so the dhcpdb file in c:\temp isn't created yet.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
jim3725

ASKER
How do I get out of the command when the export is finished, I am still in the netsh > prompt.
I've tried quit or exit but that doesn't work.
Mahesh

OK

By default, Windows Server automatically backs up the DHCP database files and registry configuration every 60 minutes and saves the backed up information in the \System32\DHCP\Backup folder

try below command to backup dhcp through netsh instead of export
This can be imported through netsh if wanted to

netsh dhcp server \\servername backup destdir
Ex:
netsh dhcp server backup C:\Backups\DHCP

If you didn't mention dhcp server name \ IP, it will assume local server
This will back up DHCP registry configuration and DHCP database file (.mdb format) to the destinated folder.
jim3725

ASKER
This works better in the batch file. Do I do a restore on the spare server, what's the command to replace the import side since it's a mdb file ?
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
ASKER CERTIFIED SOLUTION
Mahesh

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
jim3725

ASKER
Thanks Mahesh for assisting me. I do a BMR on these two windows 2008 servers, so i could restore these files from that source if needed. I will try the netsh with mdb extension and see how it works, along with documenting the scope.
Seth Simmons

I've requested that this question be deleted for the following reason:

Not enough information to confirm an answer.
jim3725

ASKER
very helpful throughout the entire process.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.