-
Notifications
You must be signed in to change notification settings - Fork 500
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor backup #301
Merged
Merged
refactor backup #301
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
a1c3b7a
refactor backup
tennix 5607cd9
address comment
tennix 9605a08
create a separate full backup section
gregwebs 75775bd
add command to create backup/restore
tennix cfaabaa
Merge branch 'master' into refactor-backup
tennix 562a1b8
address comment
tennix 9a7035a
Merge branch 'refactor-backup' of tennix.github.com:tennix/tidb-opera…
tennix 6531290
Merge branch 'master' into refactor-backup
tennix e0e2436
address comment
tennix f65f4eb
Merge branch 'refactor-backup' of tennix.github.com:tennix/tidb-opera…
tennix 9ccd3fe
fail when mode is neither backup nor restore
tennix 8970a0e
tiny fix
tennix File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
{{- if .Values.backup.create }} | ||
{{- if eq .Values.mode "backup" }} | ||
1. Watch backup job is created | ||
watch kubectl get jobs --namespace {{ .Release.Namespace }} -l app.kubernetes.io/component=backup | ||
2. Wait until backup pods becomes completed | ||
watch kubectl get po --namespace {{ .Release.Namespace }} -l app.kubernetes.io/component=backup -o wide | ||
{{- end -}} | ||
{{- if .Values.restore.create }} | ||
{{- else if eq .Values.mode "restore" }} | ||
1. Watch restore job is created | ||
watch kubectl get jobs --namespace {{ .Release.Namespace }} -l app.kubernetes.io/instance={{ .Release.Name }} -o wide | ||
2. Wait until restore pod becomes completed | ||
watch kubectl get po --namespace {{ .Release.Namespace }} -l app.kubernetes.io/component=restore | ||
{{- else }} | ||
{{ fail (printf "invalid mode: %s" .Values.mode) }} | ||
{{- end -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
27 changes: 14 additions & 13 deletions
27
charts/tidb-backup/templates/scripts/_start_backup.sh.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,30 @@ | ||
set -euo pipefail | ||
dirname=backup-`date +%Y-%m-%dT%H%M%S`-${MY_POD_NAME} | ||
|
||
host=`echo {{ .Values.clusterName }}_TIDB_SERVICE_HOST | tr '[a-z]' '[A-Z]' | tr '-' '_'` | ||
|
||
mkdir -p /data/${dirname}/ | ||
cp /savepoint-dir/savepoint /data/${dirname}/ | ||
dirname=/data/${BACKUP_NAME} | ||
mkdir -p ${dirname} | ||
cp /savepoint-dir/savepoint ${dirname}/ | ||
|
||
/mydumper \ | ||
--outputdir=/data/${dirname} \ | ||
--outputdir=${dirname} \ | ||
--host=`eval echo '${'$host'}'` \ | ||
--port=4000 \ | ||
--user={{ .Values.backup.user }} \ | ||
--user=${TIDB_USER} \ | ||
--password=${TIDB_PASSWORD} \ | ||
{{ .Values.backup.options }} | ||
{{ .Values.backupOptions }} | ||
|
||
{{- if .Values.backup.gcp }} | ||
{{- if .Values.gcp }} | ||
uploader \ | ||
--cloud=gcp \ | ||
--bucket={{ .Values.backup.gcp.bucket }} \ | ||
--backup-dir=/data/${dirname} | ||
--bucket={{ .Values.gcp.bucket }} \ | ||
--backup-dir=${dirname} | ||
{{- end }} | ||
|
||
{{- if .Values.backup.ceph }} | ||
{{- if .Values.ceph }} | ||
uploader \ | ||
--cloud=ceph \ | ||
--bucket={{ .Values.backup.ceph.bucket }} \ | ||
--endpoint={{ .Values.backup.ceph.endpoint }} \ | ||
--backup-dir=/data/${dirname} | ||
--bucket={{ .Values.ceph.bucket }} \ | ||
--endpoint={{ .Values.ceph.endpoint }} \ | ||
--backup-dir=${dirname} | ||
{{- end }} |
29 changes: 14 additions & 15 deletions
29
charts/tidb-backup/templates/scripts/_start_restore.sh.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,30 @@ | ||
set -euo pipefail | ||
|
||
dirname=restore-`date +%Y-%m-%dT%H%M%S`-${MY_POD_NAME} | ||
dataDir=/data/${dirname} | ||
mkdir -p ${dataDir}/ | ||
dirname=/data/${BACKUP_NAME} | ||
mkdir -p ${dirname} | ||
host=`echo {{ .Values.clusterName }}_TIDB_SERVICE_HOST | tr '[a-z]' '[A-Z]' | tr '-' '_'` | ||
|
||
{{- if .Values.restore.gcp }} | ||
{{- if .Values.gcp }} | ||
downloader \ | ||
--cloud=gcp \ | ||
--bucket={{ .Values.restore.gcp.bucket }} \ | ||
--srcDir={{ .Values.restore.srcDir }} \ | ||
--destDir=${dataDir} | ||
--bucket={{ .Values.gcp.bucket }} \ | ||
--srcDir=${BACKUP_NAME} \ | ||
--destDir=${dirname} | ||
{{- end }} | ||
|
||
{{- if .Values.restore.ceph }} | ||
{{- if .Values.ceph }} | ||
downloader \ | ||
--cloud=ceph \ | ||
--bucket={{ .Values.restore.ceph.bucket }} \ | ||
--endpoint={{ .Values.restore.ceph.endpoint }} \ | ||
--srcDir={{ .Values.restore.srcDir }} \ | ||
--destDir=${dataDir} | ||
--bucket={{ .Values.ceph.bucket }} \ | ||
--endpoint={{ .Values.ceph.endpoint }} \ | ||
--srcDir=${BACKUP_NAME} \ | ||
--destDir=${dirname} | ||
{{- end }} | ||
|
||
/loader \ | ||
-d ${dataDir}/{{ .Values.restore.srcDir }} \ | ||
-d ${dirname} \ | ||
-h `eval echo '${'$host'}'` \ | ||
-u {{ .Values.restore.user }} \ | ||
-u ${TIDB_USER} \ | ||
-p ${TIDB_PASSWORD} \ | ||
-P 4000 \ | ||
{{ .Values.restore.options }} | ||
{{ .Values.restoreOptions }} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you validate the mode? Maybe have
{{- if neq .Values.mode "restore" && neq .Values.mode "backup" }} ERROR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that should be added. But I can't find any document about
fail
orerror
in Helm template.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there is a
fail
function. Helm says they have Sprig functions. http://masterminds.github.io/sprig/flow_control.html