Diberdayakan oleh Blogger.

Windows Server 2012 - DHCP - Part 5 - backup and restore (GUI and command line)

The backup and restore of the DHCP database is a crucial operation that I wanted to review in Windows Server 2012 using both DHCP Manager as well as the Powershell cmdlets.
 
First let's take a look at the status quo of the DHCP server before the hypothetical loss of the database. We'll backup the database, delete the scopes and then see if we can restore them. In reality, we might have to rebuild the entire server and re-install the DHCP role. In this post, I'll simply adopt a scenario in which only the databases need to be restored or in which the server itself has already been restored.
 
Here is how the DHCP configuration appears. I took a couple screenshots to see if I could recreate the configuration with the restore.
 

Scope with reservations:





Reservation options:



OK... such a simple configuration might not even warrant a  backup since you could probably recreate it from scratch (if you have documented it) just as quickly. However, some DHCP servers allocate IP addresses to clients on multiple subnets (via DHCP relays) with a large variety of options, something most admins would not want to have to recreate from scratch.


BACKUP

Right click on the DHCP server and select "Backup" in the resulting menu:



 
Select a target for the backup. We'll just use the folder "DHCP-backup". In reality, we would, of course, save the backup to another location on the network or to some form of external media later stored in a safe location.





This is what the resulting backup file looks like:



The "new" folder contains these files:




So now, let's simulate the loss of the database by simply deleting it:




Confirm the choice to delete when any warning messages appear:





And there we go. The scope (with all its reservations and exclusions) is gone.






RESTORE

Now let's attempt to restore the database.

Right click on the DHCP server icon and select "Restore":



We browse to the location of the backup file:




Let the restore process restart the DHCP service:






The database is restored:




The configuration looks exactly like it did in the screenshots posted above. I'm not going to repost them here since they would be identical. I'll have to ask the reader to "take my word for it".




BACKUP and RESTORE... with Powershell

This is the process followed to backup and restore the DHCP database using the very intuitive Powershell cmdlets:

Backup-DhcpServer

and...

Restore-DhcpServer


This is the state of the (sole) DHCP scope before backup (and deletion):

PS C:\> Get-DhcpServerv4Scope | fl

ScopeId          : 10.0.0.0
Name             : MACH1
Description      :
SuperscopeName   :
SubnetMask       : 255.0.0.0
StartRange       : 10.1.1.0
EndRange         : 10.1.1.255
LeaseDuration    : 8.00:00:00
NapProfile       :
NapEnable        : False
Delay(ms)        : 0
State            : Active
Type             : Dhcp
MaxBootpClients  : 4294967295
ActivatePolicies : True




We backup the DHCP database with the following cmdlet:

PS C:\> Backup-DhcpServer -path C:\DHCP-backup


We remove the DHCP scope with the following cmdlet (note the use of the "pipeline"):

PS C:\> Get-DhcpServerv4Scope | Remove-DhcpServerv4Scope -force

We note that the scope was indeed deleted:

PS C:\> Get-DhcpServerv4Scope
PS C:\>


We then restore the database (and confirm the operation as needed):

PS C:\> Restore-DhcpServer -path C:\DHCP-backup

Confirm
The DHCP server database will be restored from the file C:\DHCP-backup. Do you want to want to perform this action?
[Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"): y
WARNING: Please restart the DHCP server for the restored database to take effect.



With the command line restore, we need to restart the DHCP service manually. Fortunately, there is a PowerShell cmdlet for that: 

PS C:\> Restart-Service "DHCP Server"

WARNING: Waiting for service 'DHCP Server (DHCPServer)' to start...
WARNING: Waiting for service 'DHCP Server (DHCPServer)' to start...

The scope is restored:


PS C:\> Get-DhcpServerv4Scope | fl

ScopeId          : 10.0.0.0
Name             : MACH1
Description      :
SuperscopeName   :
SubnetMask       : 255.0.0.0
StartRange       : 10.1.1.0
EndRange         : 10.1.1.255
LeaseDuration    : 8.00:00:00
NapProfile       :
NapEnable        : False
Delay(ms)        : 0
State            : Active
Type             : Dhcp
MaxBootpClients  : 4294967295
ActivatePolicies : True





Thank you for reading the article about Windows Server 2012 - DHCP - Part 5 - backup and restore (GUI and command line) on the blog NEW TECH If you want to disseminate this article on please list the link as the source, and if this article was helpful please bookmark this page in your web browser by pressing Ctrl + D on your keyboard keys.

New articles :