-
Notifications
You must be signed in to change notification settings - Fork 501
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
93 additions
and
73 deletions.
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
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 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
33 changes: 20 additions & 13 deletions
33
charts/tidb-cluster/templates/scripts/_start_scheduled_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,36 +1,43 @@ | ||
set -euo pipefail | ||
dirname=scheduled-backup-`date +%Y-%m-%dT%H%M%S`-${MY_POD_NAME} | ||
host=`echo {{ template "cluster.name" . }}_TIDB_SERVICE_HOST | tr '[a-z]' '[A-Z]' | tr '-' '_'` | ||
|
||
mkdir -p /data/${dirname}/ | ||
cp /savepoint-dir/savepoint /data/${dirname}/ | ||
host=$(getent hosts {{ template "cluster.name" . }}-tidb | head | awk '{print $1}') | ||
|
||
# the content of savepoint file is: | ||
# commitTS = 408824443621605409 | ||
savepoint=`cat /data/${dirname}/savepoint | cut -d "=" -f2 | sed 's/ *//g'` | ||
dirname=/data/scheduled-backup-`date +%Y-%m-%dT%H%M%S`-${MY_POD_NAME} | ||
echo "making dir ${dirname}" | ||
mkdir -p ${dirname} | ||
|
||
cat /data/${dirname}/savepoint | ||
gc_life_time=`/usr/bin/mysql -h${host} -P4000 -u{{ .Values.scheduledBackup.user }} -p${TIDB_PASSWORD} -Nse "select variable_value from mysql.tidb where variable_name='tikv_gc_life_time';"` | ||
echo "Old TiKV GC life time is ${gc_life_time}" | ||
|
||
echo "Increase TiKV GC life time to 3h" | ||
/usr/bin/mysql -h${host} -P4000 -u{{ .Values.scheduledBackup.user }} -p${TIDB_PASSWORD} -Nse "update mysql.tidb set variable_value='3h' where variable_name='tikv_gc_life_time';" | ||
/usr/bin/mysql -h${host} -P4000 -u{{ .Values.scheduledBackup.user }} -p${TIDB_PASSWORD} -Nse "select variable_name,variable_value from mysql.tidb where variable_name='tikv_gc_life_time';" | ||
|
||
/mydumper \ | ||
--outputdir=/data/${dirname} \ | ||
--host=`eval echo '${'$host'}'` \ | ||
--outputdir=${dirname} \ | ||
--host=${host} \ | ||
--port=4000 \ | ||
--user={{ .Values.scheduledBackup.user }} \ | ||
--password=${TIDB_PASSWORD} \ | ||
--tidb-snapshot=${savepoint} \ | ||
--long-query-guard=3600 \ | ||
--tidb-force-priority=LOW_PRIORITY \ | ||
{{ .Values.scheduledBackup.options }} | ||
|
||
echo "Reset TiKV GC life time to ${gc_life_time}" | ||
/usr/bin/mysql -h${host} -P4000 -u{{ .Values.scheduledBackup.user }} -p${TIDB_PASSWORD} -Nse "update mysql.tidb set variable_value='${gc_life_time}' where variable_name='tikv_gc_life_time';" | ||
/usr/bin/mysql -h${host} -P4000 -u{{ .Values.scheduledBackup.user }} -p${TIDB_PASSWORD} -Nse "select variable_name,variable_value from mysql.tidb where variable_name='tikv_gc_life_time';" | ||
|
||
{{- if .Values.scheduledBackup.gcp }} | ||
uploader \ | ||
--cloud=gcp \ | ||
--bucket={{ .Values.scheduledBackup.gcp.bucket }} \ | ||
--backup-dir=/data/${dirname} | ||
--backup-dir=${dirname} | ||
{{- end }} | ||
|
||
{{- if .Values.scheduledBackup.ceph }} | ||
uploader \ | ||
--cloud=ceph \ | ||
--bucket={{ .Values.scheduledBackup.ceph.bucket }} \ | ||
--endpoint={{ .Values.scheduledBackup.ceph.endpoint }} \ | ||
--backup-dir=/data/${dirname} | ||
--backup-dir=${dirname} | ||
{{- 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 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 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