备份DHCP服务器
$today = get-date $todayu = get-date -format 'yyyyMMdd' #备份DHCP数据库,用于还原到本地 Backup-DhcpServer -ComputerName dhcp1.uxin.youxinpai.com -Path C:Windowssystem32dhcpackup #导出DHCP配置,恢复的时候,只用Import-DhcpServer即可,可以恢复到新DHCP服务器 Export-DhcpServer -ComputerName dhcp1.uxin.youxinpai.com -File C:Backupdhcp1_export_$todayu.xml xcopy.exe /s /y C:Backupdhcp1_export_$todayu.xml \192.168.200.249D$BackupDHCP_Export xcopy.exe /s /y C:Windowssystem32dhcpackup \192.168.200.249D$BackupDHCP_Backup
清除早于14天的数据
#清除DHCP服务器的备份文件:删除早于14天的备份文件 $Files = Get-ChildItem –Path D:BackupDHCP_Backup Foreach ($file in $Files) { If (((get-date) - $file.lastwritetime).days -gt 14) {Remove-Item $file.Fullname -Force -Recurse} } $Files2 = Get-ChildItem –Path D:BackupDHCP_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:Windowssystem32dhcpackup
Import-DhcpServer -ComputerName dhcpserver.contoso.com -File C:exportsdhcpexport.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:BackupDHCP_Exportdhcp1_export_20160124.xml -Verbose -BackupPath C:dhcp02backup #导入DHCP配置到当前DHCP服务器,并对当前DHCP进行备份
3.撤销原DHCP服务器授权
4.对当前DHCP服务器授权