forked from BCDevOps/backup-container
-
Notifications
You must be signed in to change notification settings - Fork 0
/
backup.container.utils
82 lines (74 loc) · 1.69 KB
/
backup.container.utils
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
#!/bin/bash
# =================================================================================================================
# Container Utility Functions:
# -----------------------------------------------------------------------------------------------------------------
function isPostgres(){
(
if isInstalled "psql"; then
return 0
else
return 1
fi
)
}
function isMongo(){
(
if isInstalled "mongo"; then
return 0
else
return 1
fi
)
}
function isMsSql(){
(
if isInstalled "sqlcmd"; then
return 0
else
return 1
fi
)
}
function isMariaDb(){
(
# If a seperate mysql plugin is added, this check may be insufficient to establish the container type.
if isInstalled "mysql"; then
return 0
else
return 1
fi
)
}
function getContainerType(){
(
local _containerType=${UNKNOWN_DB}
_rtnCd=0
if isPostgres; then
_containerType=${POSTGRE_DB}
elif isMongo; then
_containerType=${MONGO_DB}
elif isMsSql; then
_containerType=${MSSQL_DB}
elif isMariaDb; then
_containerType=${MARIA_DB}
else
_containerType=${UNKNOWN_DB}
_rtnCd=1
fi
echo "${_containerType}"
return ${_rtnCd}
)
}
function isForContainerType(){
(
_databaseSpec=${1}
_databaseType=$(getDatabaseType ${_databaseSpec})
# If the database type has not been defined, assume the database spec is valid for the current databse container type.
if [ -z "${_databaseType}" ] || [[ "${_databaseType}" == "${CONTAINER_TYPE}" ]]; then
return 0
else
return 1
fi
)
}
# ======================================================================================