add helm charts
This commit is contained in:
32
backing-services/mssql/files/scripts/entrypoint/restore.sh
Normal file
32
backing-services/mssql/files/scripts/entrypoint/restore.sh
Normal file
@@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
|
||||
{{- if .Values.backup.enabled }}
|
||||
export database=$1;
|
||||
export now=$2;
|
||||
|
||||
if [ -z "$database" ]; then
|
||||
echo ERROR Database name is not specified at the 1st argument
|
||||
exit 1
|
||||
fi
|
||||
if [ -z "$now" ]; then
|
||||
echo "ERROR Backup time is not specified as 2nd argument"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
backuppath={{ .Values.backup.persistence.mount }}/$database-$now.bak
|
||||
|
||||
if [ -f "${backuppath}" ];then
|
||||
echo INFO - DB $database Snapshot found! Restoring...
|
||||
else
|
||||
echo ERROR - No Snapshot Found under $backuppath
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
sqlcmd -C \
|
||||
-S {{ include "mssql.primary.fullname" . }}.{{ include "common.names.namespace" $ }}.svc.{{ .Values.clusterDomain }} \
|
||||
-U sa -P "$MSSQL_SA_PASSWORD" \
|
||||
-e -Q "RESTORE DATABASE $database FROM DISK = '$backuppath'"
|
||||
{{- else }}
|
||||
printf "WARN No restore script available because"
|
||||
echo " .Values.backup.enabled is falsy when you deployed this helm chart"
|
||||
{{- end }}
|
||||
21
backing-services/mssql/files/sql/00_create_db_owner_user.sql
Normal file
21
backing-services/mssql/files/sql/00_create_db_owner_user.sql
Normal file
@@ -0,0 +1,21 @@
|
||||
-- Credits for https://stackoverflow.com/a/52484134/747579
|
||||
{{- if .Values.auth.createLogin }}
|
||||
USE [master]
|
||||
GO
|
||||
CREATE LOGIN [{{ .Values.auth.username }}] WITH PASSWORD=N'$(MSSQL_PASSWORD)'
|
||||
GO
|
||||
{{- end }}
|
||||
{{- if .Values.auth.username }}
|
||||
USE [master]
|
||||
GO
|
||||
CREATE USER [{{ .Values.auth.username }}] FOR LOGIN [{{ .Values.auth.username }}]
|
||||
GO
|
||||
{{- end }}
|
||||
|
||||
{{- if and .Values.auth.database .Values.auth.username }}
|
||||
USE [{{ .Values.auth.database }}]
|
||||
GO
|
||||
CREATE USER [{{ .Values.auth.username }}] FOR LOGIN [{{ .Values.auth.username }}]
|
||||
ALTER ROLE db_owner ADD MEMBER [{{ .Values.auth.username }}]
|
||||
GO
|
||||
{{- end }}
|
||||
Reference in New Issue
Block a user