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.bareos.org/downloads/depkgs-mingw32/strawberry-perl-5.10.1.0.msi
9# * Install the latest version of Bareos 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# * 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 bareos, and run the "MSSQLJob" backup job, then
25#  restore it.
26#
27TestName="win32-mssql-test"
28. scripts/functions
29
30scripts/cleanup
31scripts/copy-test-confs
32cp scripts/win32-bareos-dir-systemstate.conf bin/bareos-dir.conf
33
34echo "Connect with Win32 server"
35URL=http://$WIN32_ADDR:8091
36wget -qO $tmp/stop.log "$URL/stop"
37wget -qO $tmp/update.log "$URL/set_director_name?name=$HOST-dir;pass=$WIN32_PASSWORD"
38wget -qO $tmp/start.log "$URL/start"
39set -e
40wget -qO - "$URL/check_mssql?user=$WIN32_MSSQL_USER;pass=$WIN32_MSSQL_PASS" | grep OK
41wget -qO - "$URL/setup_mssql_db?db=db$$" | grep OK
42set +e
43
44echo "Start test"
45start_test
46
47cat <<END_OF_DATA >${cwd}/tmp/bconcmds
48@output
49messages
50@$out ${cwd}/tmp/log1.out
51status client=$WIN32_CLIENT
52label storage=File volume=TestVolume001
53run job=MSSQLJob storage=File yes
54wait
55messages
56quit
57END_OF_DATA
58
59run_bareos
60
61wget -qO - "$URL/cleanup_mssql_db?db=db$$" | grep OK > /dev/null
62if [ $? -ne 0 ]; then
63    print_debug "ERROR: can't remove mssql db$$"
64    estat=1
65fi
66
67cat <<END_OF_DATA >${cwd}/tmp/bconcmds
68@#
69@# now do a restore
70@#
71@$out ${cwd}/tmp/log2.out
72restore where=/ storage=File
735
74cd @MSSQL/
75cd SqlServerWriter/
76cd WIN2003/
77m db$$
78done
79yes
80wait
81messages
82quit
83END_OF_DATA
84
85run_bconsole
86
87check_for_zombie_jobs storage=File
88stop_bareos
89
90check_two_logs
91
92wget -qO - "$URL/online_mssql_db?mdf=db$$;db=restoredb$$" | grep OK > /dev/null
93if [ $? -ne 0 ]; then
94    print_debug "ERROR: can't put db$$ online"
95    estat=1
96fi
97
98wget -qO - "$URL/test_mssql_content?db=restoredb$$" | grep OK > /dev/null
99if [ $? -ne 0 ]; then
100    print_debug "ERROR: can't get content of restoredb$$"
101    estat=1
102fi
103
104wget -qO $tmp/cleanup.log "$URL/cleanup_mssql_db?db=restoredb$$"
105
106end_test
107