Skip to content

Commit

Permalink
Update configmap-script.yaml (#151)
Browse files Browse the repository at this point in the history
* Update configmap-script.yaml

for backup a list of database not juste all or a single one

Signed-off-by: Frédéric COELHO <[email protected]>

* update chart version to 6.1.0

Signed-off-by: Frédéric COELHO <[email protected]>

* update mysqldump readme for mysql.db for multi db

Signed-off-by: Frédéric COELHO <[email protected]>

* update documentation from values.yaml

Signed-off-by: Frédéric COELHO <[email protected]>

* fixed spaces in configuration table for mysql.db line in readme file

Signed-off-by: Frédéric COELHO <[email protected]>

* Update Chart.yaml

Signed-off-by: Frédéric COELHO <[email protected]>

* Update Chart.yaml

Signed-off-by: Frédéric COELHO <[email protected]>

---------

Signed-off-by: Frédéric COELHO <[email protected]>
  • Loading branch information
sekot authored Oct 5, 2023
1 parent 95dca44 commit f08f1ea
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 17 deletions.
2 changes: 1 addition & 1 deletion charts/mysqldump/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: v2
version: 6.1.0
version: 6.2.0
appVersion: v3.1.1
description: A Helm chart to help backup MySQL databases using mysqldump
name: mysqldump
Expand Down
4 changes: 2 additions & 2 deletions charts/mysqldump/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ The following tables lists the configurable parameters of the mysqldump chart an
| image.repository | Name of image to use | monotek/gcloud-mysql |
| image.tag | Version of image to use (uses appVersion form Chart.yaml as default if not set) | "" |
| image.pullPolicy | Pull Policy to use for image | IfNotPresent |
| mysql.db | single mysql db to backup (optional) | mysql |
| mysql.db | mysql db(s) to backup (optional) | mysql |
| mysql.host | mysql host to backup | mysql |
| mysql.username | mysql username | root |
| mysql.password | mysql password | "" |
Expand All @@ -72,7 +72,7 @@ The following tables lists the configurable parameters of the mysqldump chart an
| persistence.storageClass | storage class to use for PVC | |
| persistence.subPath | subPath for PVC | |
| allDatabases.enabled | backup all databases | true |
| allDatabases.SingleSqlFile | backup all databases to single file | false |
| allDatabases.SingleSqlFile | backup all databases to single file (works with mysql.db too) | false |
| housekeeping.enabled | delete olf backups in pvc | true |
| housekeeping.keepDays | keep last x days of backups in PVC | 10 |
| saveToDirectory | saves the sql backup to a directory named like the database or alldatabases | false |
Expand Down
29 changes: 17 additions & 12 deletions charts/mysqldump/templates/configmap-script.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,27 +39,32 @@ data:
{{ end -}}
{{ end -}}
{{ if and (.Values.mysql.db) (eq .Values.allDatabases.enabled false) }}
MYSQL_DB="{{ .Values.mysql.db }}"
echo "Backing up single db ${MYSQL_DB}"
{{ if .Values.saveToDirectory }}mkdir -p "${BACKUP_DIR}"/"${MYSQL_DB}"{{ end }}
mysqldump ${MYSQL_OPTS} -h ${MYSQL_HOST} -P ${MYSQL_PORT} -u ${MYSQL_USERNAME} --databases ${MYSQL_DB} | gzip > ${BACKUP_DIR}/{{ if .Values.saveToDirectory }}${MYSQL_DB}/{{ end }}${TIMESTAMP}_${MYSQL_DB}.sql.gz
rc=$?
{{ else if and (.Values.allDatabases.enabled) (eq .Values.allDatabases.singleBackupFile false)}}
for MYSQL_DB in $(mysql -h "${MYSQL_HOST}" -P ${MYSQL_PORT} -u ${MYSQL_USERNAME} -B -N -e "SHOW DATABASES;"|egrep -v '^(information|performance)_schema$'); do
{{ if (eq .Values.allDatabases.singleBackupFile false) }}
{{ if and (.Values.mysql.db) (eq .Values.allDatabases.enabled false) }}
MYSQL_DBS="{{ .Values.mysql.db }}"
{{ else if (.Values.allDatabases.enabled) }}
MYSQL_DBS=$(mysql -h "${MYSQL_HOST}" -P ${MYSQL_PORT} -u ${MYSQL_USERNAME} -B -N -e "SHOW DATABASES;"|egrep -v '^(information|performance)_schema$')
{{ end }}
for MYSQL_DB in $MYSQL_DBS; do
echo "Backing up db ${MYSQL_DB}"
{{ if .Values.saveToDirectory }}mkdir -p "${BACKUP_DIR}"/"${MYSQL_DB}"{{ end }}
mysqldump ${MYSQL_OPTS} -h ${MYSQL_HOST} -P ${MYSQL_PORT} -u ${MYSQL_USERNAME} --databases ${MYSQL_DB} | gzip > ${BACKUP_DIR}/{{ if .Values.saveToDirectory }}${MYSQL_DB}/{{ end }}${TIMESTAMP}_${MYSQL_DB}.sql.gz
rc=$?
done
{{ else if and (.Values.allDatabases.enabled) (.Values.allDatabases.singleBackupFile) }}
echo "Backing up all databases"
{{ else if (.Values.allDatabases.singleBackupFile) }}
MYSQL_DB="alldatabases"
{{ if .Values.saveToDirectory }}mkdir -p "${BACKUP_DIR}"/"${MYSQL_DB}"{{ end }}
{{ if and (.Values.mysql.db) (eq .Values.allDatabases.enabled false) }}
echo "Backing up all this databases {{ .Values.mysql.db }}"
mysqldump ${MYSQL_OPTS} -h ${MYSQL_HOST} -P ${MYSQL_PORT} -u ${MYSQL_USERNAME} --databases {{ .Values.mysql.db }} | gzip > ${BACKUP_DIR}/{{ if .Values.saveToDirectory }}${MYSQL_DB}/{{ end }}${TIMESTAMP}_${MYSQL_DB}.sql.gz
rc=$?
{{ else if (.Values.allDatabases.enabled) }}
echo "Backing up all databases"
mysqldump ${MYSQL_OPTS} -h ${MYSQL_HOST} -P ${MYSQL_PORT} -u ${MYSQL_USERNAME} --all-databases | gzip > ${BACKUP_DIR}/{{ if .Values.saveToDirectory }}${MYSQL_DB}/{{ end }}${TIMESTAMP}_${MYSQL_DB}.sql.gz
rc=$?
{{- end -}}
{{ end }}
{{ end }}
{{- if or (.Values.upload.googlestoragebucket.enabled) (.Values.upload.ssh.enabled) (.Values.upload.openstack.enabled) (.Values.upload.s3.enabled) -}}
{{ if .Values.upload.ssh.enabled -}}
Expand Down
4 changes: 2 additions & 2 deletions charts/mysqldump/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ mysql:
# no password means random value
password: ""
port: 3306
# db name for single db backup
# db name for db(s) backup
db: ""
# Get password from existing secret
existingSecret: ""
Expand All @@ -37,7 +37,7 @@ mysql:
# use --all-databases if enabled
allDatabases:
enabled: true
# creates single backup file with all databases
# creates single backup file with all databases (works with mysql.db too)
singleBackupFile: false

# options to pass to mysqldump
Expand Down

0 comments on commit f08f1ea

Please sign in to comment.