码迷,mamicode.com
首页 > 其他好文 > 详细

备份DHCP服务器

时间:2015-10-22 14:00:24      阅读:281      评论:0      收藏:0      [点我收藏+]

标签:

备份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即可
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_Exportxcopy.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服务器

标签:

原文地址:http://www.cnblogs.com/dreamer-fish/p/4900681.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!