-
-
Notifications
You must be signed in to change notification settings - Fork 24
/
prerequisites.download_databases.sh
executable file
·84 lines (73 loc) · 4.56 KB
/
prerequisites.download_databases.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/bash
# Enrique Catalá:
# Web: https://www.clouddataninjas.com
# Linkedin: https://www.linkedin.com/in/enriquecatala/
# Support: https://github.com/sponsors/enriquecatala
# Define the backups directory
BACKUPS_DIR="./Backups"
# check if WideWorldImporters-Full.bak exists
if [ ! -f "$BACKUPS_DIR/WideWorldImporters-Full.bak" ]; then
echo "*********** Downloading WideWorldImporters-Full.bak..." | tee -a ./config.log
curl -k -L -o $BACKUPS_DIR/WideWorldImporters-Full.bak https://github.com/Microsoft/sql-server-samples/releases/download/wide-world-importers-v1.0/WideWorldImporters-Full.bak
else
echo "*********** WideWorldImporters-Full.bak already exists. Skipping download." | tee -a ./config.log
fi
# check if AdventureWorks2017.bak exists
if [ ! -f "$BACKUPS_DIR/AdventureWorks2017.bak" ]; then
echo "*********** Downloading AdventureWorks2017.bak..." | tee -a ./config.log
curl -k -L -o $BACKUPS_DIR/AdventureWorks2017.bak https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks/AdventureWorks2017.bak
else
echo "*********** AdventureWorks2017.bak already exists. Skipping download." | tee -a ./config.log
fi
# Conditional downloads based on INCLUDE_ALL_DATABASES environment variable
# If INCLUDE_ALL_DATABASES is set to 1, download all databases
# INCLUDE_ALL_DATABASES=1 ./prerequisites.download_databases.sh
if [ "${INCLUDE_ALL_DATABASES}" = "1" ]; then
#check if AdventureWorks2016.bak exists
if [ ! -f "$BACKUPS_DIR/AdventureWorks2016.bak" ]; then
echo "*********** Downloading AdventureWorks2016.bak..." | tee -a ./config.log
curl -k -L -o $BACKUPS_DIR/AdventureWorks2016.bak https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks/AdventureWorks2016.bak
else
echo "*********** AdventureWorks2016.bak already exists. Skipping download." | tee -a ./config.log
fi
#check if AdventureWorks2014.bak exists
if [ ! -f "$BACKUPS_DIR/AdventureWorks2014.bak" ]; then
echo "*********** Downloading AdventureWorks2014.bak..." | tee -a ./config.log
curl -k -L -o $BACKUPS_DIR/AdventureWorks2014.bak https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks/AdventureWorks2014.bak
else
echo "*********** AdventureWorks2014.bak already exists. Skipping download." | tee -a ./config.log
fi
#check if AdventureWorks2012.bak exists
if [ ! -f "$BACKUPS_DIR/AdventureWorks2012.bak" ]; then
echo "*********** Downloading AdventureWorks2012.bak..." | tee -a ./config.log
curl -k -L -o $BACKUPS_DIR/AdventureWorks2012.bak https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks/AdventureWorks2012.bak
else
echo "*********** AdventureWorks2012.bak already exists. Skipping download." | tee -a ./config.log
fi
#check if AdventureWorksDW2017.bak exists
if [ ! -f "$BACKUPS_DIR/AdventureWorksDW2017.bak" ]; then
echo "*********** Downloading AdventureWorksDW2017.bak..." | tee -a ./config.log
curl -L -o $BACKUPS_DIR/AdventureWorksDW2017.bak https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks/AdventureWorksDW2017.bak
else
echo "*********** AdventureWorksDW2017.bak already exists. Skipping download." | tee -a ./config.log
fi
#check if WideWorldImportersDW-Full exists
if [ ! -f "$BACKUPS_DIR/WideWorldImportersDW-Full.bak" ]; then
echo "*********** Downloading WideWorldImportersDW-Full.bak..." | tee -a ./config.log
curl -L -o $BACKUPS_DIR/WideWorldImportersDW-Full.bak https://github.com/Microsoft/sql-server-samples/releases/download/wide-world-importers-v1.0/WideWorldImportersDW-Full.bak
else
echo "*********** WideWorldImportersDW-Full.bak already exists. Skipping download." | tee -a ./config.log
fi
# # check if StackOverflow2010.7z exists
# if [ ! -f "$BACKUPS_DIR/StackOverflow2010.7z" ]; then
# echo "*********** Downloading StackOverflow2010.7z..." | tee -a ./config.log
# curl -k -L -o $BACKUPS_DIR/StackOverflow2010.7z http://downloads.brentozar.com.s3.amazonaws.com/StackOverflow2010.7z
# # Unzip StackOverflow2010
# 7za x $BACKUPS_DIR/StackOverflow2010.7z -o$BASE_DIR/data/
# else
# echo "*********** StackOverflow2010.7z already exists. Skipping download." | tee -a ./config.log
# fi
else
echo 'Only selected databases are downloaded as INCLUDE_ALL_DATABASES is not set to 1.'
echo 'To download all databases: INCLUDE_ALL_DATABASES=1 ./prerequisites.download_databases.sh'
fi