︿
Top

前言

若您所建立的 DNS Service 未跟 Active Directory 整合,則您建立的 DNS 為標準主要區,若是跟 Active Directory 整合則為 Active Directory 整合主要區,本文為說明備份 DNS 標準主要區。
  • DNS 未 跟 AD 整合: 標準主要區。
  • DNS 有 跟 AD 整合: Active Directory 整合主要區。



如何備份 DNS 標準主要區?

1. 備份二處機碼 (Registry)
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\DNS Server
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\DNS

2. 備份 .dns 檔案
C:\Windows\System32\DNS 下


如何還原 DNS 標準主要區?

1. 停止 DNS Service。
2. 匯入備份的機碼 (Registry)。
3. 貼上所複製的 .dns 檔案至 C:\Windows\System32\DNS 下。
4. 啟動 DNS Service。


實作環境

  • Windows Server 2003


自動備份 DNS 實作

您可將下面內容貼至筆記本後存檔為 .bat 並配合排定的工作來達成自動備份 DNS 標準主要區資料的目的,以下實作為利用 xcopy、regedit 指令來自動備份 DNS 標準主要區:

  • 匯出 DNS 機碼: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\DNS Server
  • 匯出 DNS 機碼: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\DNS
  • DNS 標準主要區備份來源: C:\WINDOWS\system32\dns
  • DNS 標準主要區備份至: D:\dns\當天日期\
  • 備份時 Log 寫入至: D:\log\reg\當天日期.log
  • 備份使用指令: xcopy /S (/S 複製每個目錄及其包含的子目錄,不複製空目錄)

rem ----- 將匯出機碼時間寫入 log 紀錄中 -----
echo 開始匯出機碼及複製 .dns >> D:\log\reg\%date:~0,4%%date:~5,2%%date:~8,2%.log
TIME /T    >> D:\log\reg\%date:~0,4%%date:~5,2%%date:~8,2%.log
rem ----- 開始匯出機碼及複製 .dns -----
rem /S 複製每個目錄及其包含的子目錄,不複製空目錄
C:\WINDOWS\regedit.exe /e D:\dns\%date:~0,4%%date:~5,2%%date:~8,2%\DNS_Server.reg "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\DNS Server"
C:\WINDOWS\regedit.exe /e D:\dns\%date:~0,4%%date:~5,2%%date:~8,2%\DNS.reg "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\DNS"
xcopy C:\WINDOWS\system32\dns D:\dns\%date:~0,4%%date:~5,2%%date:~8,2%\ /S >> D:\log\reg\%date:~0,4%%date:~5,2%%date:~8,2%.log
rem ----- 將結束匯出機碼及複製 .dns時間寫入 log 紀錄中 -----
echo 結束匯出機碼及複製 .dns >> D:\log\reg\%date:~0,4%%date:~5,2%%date:~8,2%.log
TIME /T    >> D:\log\reg\%date:~0,4%%date:~5,2%%date:~8,2%.log



參考

文章標籤: