DHCP服务器备份、还原、迁移

备份DHCP服务器

$today = get-date
$todayu = get-date -format 'yyyyMMdd'
#备份DHCP数据库,用于还原到本地
Backup-DhcpServer -ComputerName dhcp1.uxin.youxinpai.com -Path C:\Windows\system32\dhcp\backup
#导出DHCP配置,恢复的时候,只用Import-DhcpServer即可,可以恢复到新DHCP服务器
Export-DhcpServer -ComputerName dhcp1.uxin.youxinpai.com -File C:\Backup\dhcp1_export_$todayu.xml

xcopy.exe /s /y C:\Backup\dhcp1_export_$todayu.xml \\192.168.200.249\D$\Backup\DHCP_Export\
xcopy.exe /s /y C:\Windows\system32\dhcp\backup \\192.168.200.249\D$\Backup\DHCP_Backup

清除早于14天的数据

#清除DHCP服务器的备份文件:删除早于14天的备份文件
$Files = Get-ChildItem –Path D:\Backup\DHCP_Backup
Foreach ($file in $Files)
{
 If (((get-date) - $file.lastwritetime).days -gt 14)
     {Remove-Item $file.Fullname -Force -Recurse}    
}

$Files2 = Get-ChildItem –Path D:\Backup\DHCP_Export
Foreach ($file2 in $Files2)
{
 If (((get-date) - $file2.lastwritetime).days -gt 14)
     {Remove-Item $file2.Fullname -Force}    
}

 

Restore-DhcpServer -ComputerName dhcpserver.contoso.com -Path C:\Windows\system32\dhcp\backup

Import-DhcpServer -ComputerName dhcpserver.contoso.com -File C:\exports\dhcpexport.xml -BackupPath C:\dhcpbackup\

参考:https://technet.microsoft.com/zh-cn/library/jj553823.aspx

 

迁移DHCP服务器:

原DHCP服务器宕后恢复步骤:
1.设置当前DHCP服务为自启动
2.Import-DHCPServer -ComputerName NEWDHCP02.uxin.youxinpai.com -File D:\Backup\DHCP_Export\dhcp1_export_20160124.xml -Verbose -BackupPath C:\dhcp02backup #导入DHCP配置到当前DHCP服务器,并对当前DHCP进行备份
3.撤销原DHCP服务器授权
4.对当前DHCP服务器授权

 

posted on 2015-10-22 13:43  momingliu11  阅读(2206)  评论(0编辑  收藏  举报