]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/win32-mssql-systemstate-test
regress: test restore object in plugin-test
[bacula/bacula] / regress / tests / win32-mssql-systemstate-test
1 #!/bin/sh
2 #
3 # How to use this test
4 # --------------------
5 #
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 # * 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 # * Run this script with the proper config settings about WIN32
15 #   see win32-fd-test
16 #
17 # * Install MSSQL with default options, put database username in config
18 #  WIN32_MSSQL_USER=sa
19 #  WIN32_MSSQL_PASS=password
20 #
21 # Note, once everything is setup, and you have run the above once
22 #  you can simply run the first part of this script prior to the URL=
23 #  to get the proper conf files loaded in bin, then manually
24 #  start bacula, and run the "SS_SQLJob" backup job, then
25 #  restore it.
26 #
27 TestName="win32-mssql-systemstate-test"
28 . scripts/functions
29
30 scripts/cleanup
31 scripts/copy-test-confs
32 cp scripts/win32-bacula-dir-systemstate.conf bin/bacula-dir.conf
33
34 scripts/setup_win32
35
36 URL=http://$WIN32_ADDR:8091
37
38 wget -qO - "$URL/check_mssql?user=$WIN32_MSSQL_USER;pass=$WIN32_MSSQL_PASS" | grep OK > /dev/null
39 if [ $? != 0 ]; then
40    echo "check_msql user=$WIN32_MSSQL_USER pass=$WIN32_MSSQL_PASS failed"
41 fi
42 wget -qO - "$URL/setup_mssql_db?db=db$$" | grep OK > /dev/null
43 if [ $? != 0 ]; then
44    echo "setup_db failed"
45 fi
46
47 wget -qO - "$URL/add_registry_key?key=Test$$;val=Val$$" | grep OK > /dev/null
48 if [ $? != 0 ]; then
49    print_debug "ERROR: Can't add registry key Test$$"
50 fi
51 wget -qO - "$URL/add_registry_key?key=RemovedAtRestore$$;val=Val$$" | grep OK > /dev/null
52 if [ $? != 0 ]; then
53    print_debug "ERROR: Can't add registry key RemovedAtRestore$$"
54 fi
55
56 echo "Start test"
57 start_test
58      
59 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
60 @output
61 messages
62 @$out ${cwd}/tmp/log1.out
63 status client=$WIN32_CLIENT
64 label storage=File volume=TestVolume001
65 run job=SS_SQLJob storage=File yes
66 wait
67 messages
68 quit
69 END_OF_DATA
70
71 run_bacula
72
73 wget -qO -  "$URL/del_registry_key?key=RemovedAtRestore$$" | grep OK > /dev/null
74 if [ $? -ne 0 ]; then
75     print_debug "ERROR: can't remove key RemovedAtRestore$$ from registry"
76     estat=1
77 fi
78  
79 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
80 @output
81 @$out ${cwd}/tmp/log1.out
82 run job=SS_SQLJob storage=File yes
83 wait
84 messages
85 quit
86 END_OF_DATA
87
88 run_bconsole
89
90 wget -qO -  "$URL/del_registry_key?key=Test$$" | grep OK > /dev/null
91 if [ $? -ne 0 ]; then
92     print_debug "ERROR: can't remove key Test$$ from registry"
93     estat=1
94 fi
95
96 wget -qO - "$URL/cleanup_mssql_db?db=db$$" | grep OK > /dev/null
97 if [ $? -ne 0 ]; then
98     print_debug "ERROR: can't remove mssql db$$"
99     estat=1
100 fi
101
102 # the restore contains the name of the SQLServer instance
103 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
104 @$out ${cwd}/tmp/log3.out
105 restore where=/ storage=File
106 5
107 cd @MSSQL/
108 cd SqlServerWriter/
109 cd MSDEWriter/
110 @$out ${cwd}/tmp/host.out
111 ls
112 @$out ${cwd}/tmp/log3.out
113 quit
114 quit
115 END_OF_DATA
116
117 run_bconsole
118
119 host=`head -2 ${cwd}/tmp/host.out | tail -1`
120
121 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
122 @# 
123 @# now do a restore
124 @#
125 @$out ${cwd}/tmp/log2.out
126 restore where=/ storage=File
127 5
128 cd @SYSTEMSTATE/
129 mark Reg*
130 cd ..
131 cd @MSSQL/
132 cd SqlServerWriter/
133 cd MSDEWriter/
134 cd $host
135 m db$$
136 done
137 yes
138 wait
139 messages
140 quit
141 END_OF_DATA
142
143 run_bconsole
144
145 check_for_zombie_jobs storage=File
146 stop_bacula
147
148 check_two_logs
149
150 # with SQL 2005, the db is mounted automatically
151 wget -qO - "$URL/test_mssql_content?db=db$$" | grep OK > /dev/null
152 if [ $? -ne 0 ]; then
153
154     wget -qO - "$URL/online_mssql_db?mdf=db$$;db=restoredb$$" | grep OK > /dev/null
155     if [ $? -ne 0 ]; then
156         print_debug "ERROR: can't put db$$ online"
157         estat=1
158     fi
159     
160     wget -qO - "$URL/test_mssql_content?db=restoredb$$" | grep OK > /dev/null
161     if [ $? -ne 0 ]; then
162         print_debug "ERROR: can't get content of restoredb$$"
163         estat=1
164     fi
165
166     wget -qO $tmp/cleanup.log "$URL/cleanup_mssql_db?db=restoredb$$"
167
168 else 
169     wget -qO $tmp/cleanup.log "$URL/cleanup_mssql_db?db=db$$"
170 fi
171
172 scripts/reboot_win32
173
174 wget -qO - "$URL/get_registry_key?key=RemovedAtRestore$$;val=Val$$" | grep ERR > /dev/null
175 if [ $? -ne 0 ]; then
176     print_debug "ERROR: Should not find registry key RemovedAtRestore$$"
177     estat=1
178 fi
179
180 wget -qO - "$URL/get_registry_key?key=Test$$;val=Val$$" | grep OK > /dev/null
181 if [ $? -ne 0 ]; then
182     print_debug "ERROR: Can't find registry key Test$$"
183     estat=1
184 fi
185
186 end_test