2 rem --------------------------------------------------------------
\r
3 rem -- DNS cache save/load script
\r
6 rem -- By Yuri Voinov (c) 2014
\r
7 rem --------------------------------------------------------------
\r
10 set prefix="C:\Program Files (x86)"
\r
11 set program_path=%prefix%\Unbound
\r
12 set uc=%program_path%\unbound-control.exe
\r
13 set fname="unbound_cache.dmp"
\r
15 rem Check Unbound installed
\r
16 if exist %uc% goto start
\r
17 echo Unbound control not found. Exiting...
\r
22 rem arg1 - command (optional)
\r
23 rem arg2 - file name (optional)
\r
27 if /I "%arg1%" == "-h" goto help
\r
30 echo Loading cache from %program_path%\%fname%
\r
31 dir /a %program_path%\%fname%
\r
32 type %program_path%\%fname%|%uc% load_cache
\r
36 if defined %arg2% (goto Not_Defined) else (goto Defined)
\r
38 rem If file not specified; use default dump file
\r
40 if /I "%arg1%" == "-s" (
\r
41 echo Saving cache to %program_path%\%fname%
\r
42 %uc% dump_cache>%program_path%\%fname%
\r
43 dir /a %program_path%\%fname%
\r
48 if /I "%arg1%" == "-l" (
\r
49 echo Loading cache from %program_path%\%fname%
\r
50 dir /a %program_path%\%fname%
\r
51 type %program_path%\%fname%|%uc% load_cache
\r
55 if /I "%arg1%" == "-r" (
\r
56 echo Saving cache to %program_path%\%fname%
\r
57 dir /a %program_path%\%fname%
\r
58 %uc% dump_cache>%program_path%\%fname%
\r
60 echo Loading cache from %program_path%\%fname%
\r
61 type %program_path%\%fname%|%uc% load_cache
\r
65 rem If file name specified; use this filename
\r
67 if /I "%arg1%" == "-s" (
\r
68 echo Saving cache to %arg2%
\r
69 %uc% dump_cache>%arg2%
\r
75 if /I "%arg1%" == "-l" (
\r
76 echo Loading cache from %arg2%
\r
78 type %arg2%|%uc% load_cache
\r
82 if /I "%arg1%" == "-r" (
\r
83 echo Saving cache to %arg2%
\r
85 %uc% dump_cache>%arg2%
\r
87 echo Loading cache from %arg2%
\r
88 type %arg2%|%uc% load_cache
\r
93 echo Usage: unbound_cache.cmd [-s] or [-l] or [-r] or [-h] [filename]
\r
95 echo l - Load - default mode. Warming up Unbound DNS cache from saved file. cache-ttl must be high value.
\r
96 echo s - Save - save Unbound DNS cache contents to plain file with domain names.
\r
97 echo r - Reload - reloadind new cache entries and refresh existing cache
\r
98 echo h - this screen.
\r
99 echo filename - file to save/load dumped cache. If not specified, %program_path%\%fname% will be used instead.
\r
100 echo Note: Run without any arguments will be in default mode.
\r
101 echo Also, unbound-control must be configured.
\r