6 # * Get a working Windows OS on your network
7 # * Install strawberry perl version with msi to c:/strawberry
8 # http://www.bacula.org/downloads/depkgs-mingw32/strawberry-perl-5.10.1.0.msi
9 # * Install the latest version of Bacula FD
10 # * Copy or make accessible (Network share, VirtualBox share)
11 # regress/scripts/regress-win32.pl
12 # * Execute the script on the Windows box
13 # perl regress-win32.pl
14 # Note: port 8091 must be opened in the firewall
15 # * Run this script with the proper config settings about WIN32
16 # * do "make sed" if you want to run the test on an other host
18 # Add user auth info to ./config file to enable autologin
19 # WIN32_USER=Administrator
20 # WIN32_PASS=PasswordSecret
22 # Note, once everything is setup, and you have run the above once
23 # you can simply run the first part of this script prior to the URL=
24 # to get the proper conf files loaded in bin, then manually
25 # start bacula, and run the "systemstate" backup job, then
28 TestName="win32-full-systemstate-test"
32 scripts/copy-test-confs
33 cp scripts/win32-bacula-dir-systemstate.conf bin/bacula-dir.conf
35 URL=http://$WIN32_ADDR:8091
36 echo "Connect with Win32 server $URL"
37 wget -qO $tmp/stop.log "$URL/stop"
39 print_debug "ERROR: Stop Windows Bacula FD daemon failed."
41 wget -qO $tmp/update.log "$URL/set_director_name?name=$HOST-dir;pass=$WIN32_PASSWORD"
43 print_debug "ERROR: Set Windows Bacula director name, pasword failed"
45 wget -qO $tmp/start.log "$URL/start"
47 print_debug "ERROR: Restart Windows Bacula FD failed"
49 if [ x$WIN32_USER != x ]; then
50 wget -qO - "$URL/set_auto_logon?user=$WIN32_USER;pass=$WIN32_PASS" |grep OK
52 print_debug "ERROR: Set autologin failed"
55 wget -qO - "$URL/add_registry_key?key=Test$$;val=Val$$" | grep OK > /dev/null
57 print_debug "ERROR: Can't add registry key Test$$"
59 wget -qO - "$URL/add_registry_key?key=RemovedAtRestore$$;val=Val$$" | grep OK > /dev/null
61 print_debug "ERROR: Can't add registry key RemovedAtRestore$$"
67 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
70 @$out ${cwd}/tmp/log1.out
71 status client=$WIN32_CLIENT
72 label storage=File volume=TestVolume001
73 run job=SystemstateJob storage=File yes
82 wget -qO - "$URL/del_registry_key?key=RemovedAtRestore$$" | grep OK > /dev/null
84 print_debug "ERROR: can't remove key RemovedAtRestore$$ from registry"
88 wget -qO - "$URL/add_registry_key?key=NewTest$$;val=Val$$" |grep OK > /dev/null
90 print_debug "ERROR: can't add key NewTest$$ to registry"
94 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
95 @$out ${cwd}/tmp/log1.out
96 run job=SystemstateJob storage=File yes
104 wget -qO - "$URL/add_registry_key?key=OtherTest$$;val=Val$$" |grep OK > /dev/null
105 if [ $? -ne 0 ]; then
106 print_debug "ERROR: can't add key OtherTest$$ to registry"
112 wget -qO - "$URL/add_registry_key?key=Other$$;val=Val$$" |grep OK > /dev/null
113 if [ $? -ne 0 ]; then
114 print_debug "ERROR: can't add key Other$$ to registry"
120 # choose a random file in winsxs, delete it and see if it's restored at the end
121 # should work only on win2008, win2003 doesn't include this dir in systemstate
122 $bperl -e 'add_attribute("$conf/bacula-dir.conf", "ClientRunAfterJob", "c:/del.cmd", "Job", "SystemstateJob")'
124 wget -qO - "$URL/remove_dir?file=c:/windows/winsxs/*help*;dest=c:/del.cmd" | grep OK > /dev/null
125 if [ $? -ne 0 ]; then
126 print_debug "ERROR: can't create c:/del.cmd"
130 # should not backup many things, just run the del.cmd command at the end
131 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
133 @$out ${cwd}/tmp/log1.out
134 run job=SystemstateJob storage=File yes
142 wget -qO - "$URL/del_registry_key?key=NewTest$$" | grep OK > /dev/null
143 if [ $? -ne 0 ]; then
144 print_debug "ERROR: can't remove key NewTest$$ from registry"
148 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
152 @$out ${cwd}/tmp/log2.out
153 restore where=/ storage=File
156 mark "Registry Writer"
166 wget -qO $tmp/start.log "$URL/reboot"
168 # we need a way to start the regress-win32.pl at the start
169 while ! ping -c 1 $WIN32_ADDR > /dev/null; do
172 echo "Machine $URL supposedly rebooted"
174 echo "If the autologon doesn't work, you can double click on c:\\autologon.reg"
176 while ! wget -qO /dev/null $URL/nop; do
179 if [ $i -ge 12 ]; then # print message every minute
181 echo "== `date +%T` Waiting for reboot and autologin to $URL, you can also login and start regress-win32.pl by hand"
185 wget -qO - "$URL/get_registry_key?key=Test$$;val=Val$$" | grep OK > /dev/null
186 if [ $? -ne 0 ]; then
187 print_debug "ERROR: Can't find registry key Test$$"
191 wget -qO - "$URL/get_registry_key?key=NewTest$$;val=Val$$" | grep OK > /dev/null
192 if [ $? -ne 0 ]; then
193 print_debug "ERROR: Can't find registry key NewTest$$"
197 wget -qO - "$URL/get_registry_key?key=RemovedAtRestore$$;val=Val$$" | grep ERR > /dev/null
198 if [ $? -ne 0 ]; then
199 print_debug "ERROR: Should not find registry key RemovedAtRestore$$"
203 ################################################################
204 # Do a complete restore
206 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
208 @# now do a complete restore
210 @$out ${cwd}/tmp/log2.out
211 restore where=/ storage=File
224 check_for_zombie_jobs storage=File
229 wget -qO $tmp/start.log "$URL/reboot"
231 # we need a way to start the regress-win32.pl at the start
232 while ! ping -c 1 $WIN32_ADDR > /dev/null; do
235 echo "Machine $URL supposedly rebooted"
237 echo "If the autologon doesn't work, you can double click on c:\\autologon.reg"
238 while ! wget -qO /dev/null $URL/nop; do
241 if [ $i -ge 12 ]; then # print message every minute
243 echo "== `date +%T` Waiting for reboot and autologin to $URL, you can also login and start regress-win32.pl by hand"
247 wget -qO - "$URL/get_registry_key?key=Test$$;val=Val$$" | grep OK > /dev/null
248 if [ $? -ne 0 ]; then
249 print_debug "ERROR: Can't find registry key Test$$"
253 wget -qO - "$URL/get_registry_key?key=NewTest$$;val=Val$$" | grep OK > /dev/null
254 if [ $? -ne 0 ]; then
255 print_debug "ERROR: Can't find registry key NewTest$$"
259 wget -qO - "$URL/get_registry_key?key=RemovedAtRestore$$;val=Val$$" | grep ERR > /dev/null
260 if [ $? -ne 0 ]; then
261 print_debug "ERROR: Should not find registry key RemovedAtRestore$$"