Skip to content

Commit d8869c7

Browse files
committed
Added CURL command to download backup file automatically
1 parent 0d13643 commit d8869c7

File tree

2 files changed

+25
-14
lines changed

2 files changed

+25
-14
lines changed

samples/features/sql-big-data-cluster/bootstrap-sample-db.cmd

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ setlocal enableextensions
44
set CLUSTER_NAMESPACE=%1
55
set SQL_MASTER_IP=%2
66
set SQL_MASTER_SA_PASSWORD=%3
7-
set BACKUP_FILE_PATH=%~4
8-
set KNOX_IP=%5
9-
set KNOX_PASSWORD=%6
7+
set KNOX_IP=%3
8+
set KNOX_PASSWORD=%4
109
set STARTUP_PATH=%~dp0
1110

1211
if NOT DEFINED CLUSTER_NAMESPACE goto :usage
@@ -19,15 +18,19 @@ if NOT DEFINED KNOX_PASSWORD set KNOX_PASSWORD=%SQL_MASTER_SA_PASSWORD%
1918
set SQL_MASTER_INSTANCE=%SQL_MASTER_IP%,31433
2019
set KNOX_ENDPOINT=%KNOX_IP%:30443
2120

22-
echo Verifying sqlcmd.exe is in path & CALL WHERE /Q sqlcmd.exe || GOTO exit
23-
echo Verifying bcp.exe is in path & CALL WHERE /Q bcp.exe || GOTO exit
24-
echo Verifying kubectl.exe is in path & CALL WHERE /Q kubectl.exe || echo HINT: Install the kubernetes-cli - https://kubernetes.io/docs/tasks/tools/install-kubectl && GOTO exit
25-
echo Verifying curl.exe is in path & CALL WHERE /Q curl.exe || echo HINT: Install curl - https://curl.haxx.se/download.html && GOTO exit
21+
for %%F in (sqlcmd.exe bcp.exe kubectl.exe curl.exe) do (
22+
echo Verifying %%F is in path & CALL WHERE /Q %%F || GOTO exit
23+
)
24+
25+
pushd "%tmp%"
26+
echo Downloading sample database backup file...
27+
curl -G "https://sqlchoice.blob.core.windows.net/sqlchoice/static/tpcxbb_1gb.bak" -o tpcxbb_1gb.bak
2628

2729
REM Copy the backup file, restore the database, create necessary objects and data file
2830
echo Copying database backup file...
29-
pushd "%BACKUP_FILE_PATH%"
3031
%DEBUG% kubectl cp tpcxbb_1gb.bak mssql-master-pool-0:/var/opt/mssql/data -c mssql-server -n %CLUSTER_NAMESPACE% || goto exit
32+
33+
del tpcxbb_1gb.bak >NUL
3134
popd
3235

3336
echo Configuring sample database...

samples/features/sql-big-data-cluster/bootstrap-sample-db.sh

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,42 @@
11
#!/bin/bash
22
set -e
33
set -o pipefail
4-
USAGE_MESSAGE="USAGE: $0 <CLUSTER_NAMESPACE> <SQL_MASTER_IP> <SQL_MASTER_SA_PASSWORD> <BACKUP_FILE_PATH> <KNOX_IP> [<KNOX_PASSWORD>]"
4+
USAGE_MESSAGE="USAGE: $0 <CLUSTER_NAMESPACE> <SQL_MASTER_IP> <SQL_MASTER_SA_PASSWORD> <KNOX_IP> [<KNOX_PASSWORD>]"
55
ERROR_MESSAGE="Bootstrap of the sample database failed."
66

77
# Print usage if mandatory parameters are missing
88
: "${1:?$USAGE_MESSAGE}"
99
: "${2:?$USAGE_MESSAGE}"
1010
: "${3:?$USAGE_MESSAGE}"
1111
: "${4:?$USAGE_MESSAGE}"
12-
: "${5:?$USAGE_MESSAGE}"
1312
: "${DEBUG=}"
1413

1514
# Save the input parameters
1615
CLUSTER_NAMESPACE=$1
1716
SQL_MASTER_IP=$2
1817
SQL_MASTER_SA_PASSWORD=$3
19-
BACKUP_FILE_PATH=$4
20-
KNOX_IP=$5
21-
KNOX_PASSWORD=$6
18+
KNOX_IP=$4
19+
KNOX_PASSWORD=$5
2220
# If Knox password is not supplied then default to SQL Master password
2321
KNOX_PASSWORD=${KNOX_PASSWORD:=$SQL_MASTER_SA_PASSWORD}
2422

2523
SQL_MASTER_INSTANCE=$SQL_MASTER_IP,31433
2624
KNOX_ENDPOINT=$KNOX_IP:30443
2725

26+
27+
for util in sqlcmd.exe bcp.exe kubectl.exe curl.exe
28+
do
29+
echo Verifying $util is in path & which $util 1>NUL 2>NUL || (echo Unable to locate $util && exit 1)
30+
done
31+
2832
# Copy the backup file, restore the database, create necessary objects and data file
33+
pushd "/tmp"
34+
echo Downloading sample database backup file...
35+
$DEBUG curl -G "https://sqlchoice.blob.core.windows.net/sqlchoice/static/tpcxbb_1gb.bak" -o tpcxbb_1gb.bak
36+
2937
echo Copying database backup file...
30-
pushd "$BACKUP_FILE_PATH"
3138
$DEBUG kubectl cp tpcxbb_1gb.bak mssql-master-pool-0:/var/opt/mssql/data -c mssql-server -n $CLUSTER_NAMESPACE || (echo $ERROR_MESSAGE && exit 1)
39+
rm tpcxbb_1gb.bak
3240
popd
3341

3442
echo Configuring sample database...

0 commit comments

Comments
 (0)