From 430fa95346543c443c70436c0e90068645d37e1b Mon Sep 17 00:00:00 2001 From: DanielZhangQD <36026334+DanielZhangQD@users.noreply.github.com> Date: Thu, 27 Feb 2020 16:13:05 +0800 Subject: [PATCH] add prefix for remote storage (#1790) --- .../templates/scripts/_start_backup.sh.tpl | 13 +++++++++++++ .../templates/scripts/_start_restore.sh.tpl | 12 ++++++++++++ charts/tidb-backup/values.yaml | 3 +++ 3 files changed, 28 insertions(+) diff --git a/charts/tidb-backup/templates/scripts/_start_backup.sh.tpl b/charts/tidb-backup/templates/scripts/_start_backup.sh.tpl index f33b0d1b14..8be218a3ef 100644 --- a/charts/tidb-backup/templates/scripts/_start_backup.sh.tpl +++ b/charts/tidb-backup/templates/scripts/_start_backup.sh.tpl @@ -67,14 +67,23 @@ $creds EOF cd "${backup_base_dir}" +{{- if .Values.gcp.prefix }} +tar -cf - "${backup_name}" | pigz -p 16 \ + | rclone --config /tmp/rclone.conf rcat gcp:${bucket}/{{ .Values.gcp.prefix }}/${backup_name}/${backup_name}.tgz +{{- else }} tar -cf - "${backup_name}" | pigz -p 16 \ | rclone --config /tmp/rclone.conf rcat gcp:${bucket}/${backup_name}/${backup_name}.tgz {{- end }} +{{- end }} {{- if .Values.ceph }} uploader \ --cloud=ceph \ + {{- if .Values.ceph.prefix }} + --bucket={{ .Values.ceph.bucket }}/{{ .Values.ceph.prefix }} \ + {{- else }} --bucket={{ .Values.ceph.bucket }} \ + {{- end }} --endpoint={{ .Values.ceph.endpoint }} \ --backup-dir=${dirname} {{- end }} @@ -83,6 +92,10 @@ uploader \ uploader \ --cloud=aws \ --region={{ .Values.s3.region }} \ + {{- if .Values.s3.prefix }} + --bucket={{ .Values.s3.bucket }}/{{ .Values.s3.prefix }} \ + {{- else }} --bucket={{ .Values.s3.bucket }} \ + {{- end }} --backup-dir=${dirname} {{- end }} diff --git a/charts/tidb-backup/templates/scripts/_start_restore.sh.tpl b/charts/tidb-backup/templates/scripts/_start_restore.sh.tpl index 1489630a81..c15ffa146f 100644 --- a/charts/tidb-backup/templates/scripts/_start_restore.sh.tpl +++ b/charts/tidb-backup/templates/scripts/_start_restore.sh.tpl @@ -7,7 +7,11 @@ host=`echo {{ .Values.clusterName }}_TIDB_SERVICE_HOST | tr '[a-z]' '[A-Z]' | tr {{- if .Values.gcp }} downloader \ --cloud=gcp \ + {{- if .Values.gcp.prefix }} + --bucket={{ .Values.gcp.bucket }}/{{ .Values.gcp.prefix }} \ + {{- else }} --bucket={{ .Values.gcp.bucket }} \ + {{- end }} --srcDir=${BACKUP_NAME} \ --destDir=/data {{- end }} @@ -15,7 +19,11 @@ downloader \ {{- if .Values.ceph }} downloader \ --cloud=ceph \ + {{- if .Values.ceph.prefix }} + --bucket={{ .Values.ceph.bucket }}/{{ .Values.ceph.prefix }} \ + {{- else }} --bucket={{ .Values.ceph.bucket }} \ + {{- end }} --endpoint={{ .Values.ceph.endpoint }} \ --srcDir=${BACKUP_NAME} \ --destDir=/data @@ -25,7 +33,11 @@ downloader \ downloader \ --cloud=aws \ --region={{ .Values.s3.region }} \ + {{- if .Values.s3.prefix }} + --bucket={{ .Values.s3.bucket }}/{{ .Values.s3.prefix }} \ + {{- else }} --bucket={{ .Values.s3.bucket }} \ + {{- end }} --srcDir=${BACKUP_NAME} \ --destDir=/data {{- end }} diff --git a/charts/tidb-backup/values.yaml b/charts/tidb-backup/values.yaml index 23e9af6f39..b126855821 100644 --- a/charts/tidb-backup/values.yaml +++ b/charts/tidb-backup/values.yaml @@ -104,6 +104,7 @@ restoreUsingExistingVolume: true # backup to or restore from gcp bucket, the backup path is in the form of - gcp: {} # bucket: "" + # prefix: "" # secretName is not necessary on GKE if you use the workload identity feature # secretName is the name of the secret which stores the gcp service account credentials json file # The service account must have read/write permission to the above bucket. @@ -117,6 +118,7 @@ gcp: {} ceph: {} # endpoint: "" # bucket: "" + # prefix: "" # secretName is the name of the secret which stores ceph object store access key and secret key # You can create the secret by: # kubectl create secret generic ceph-backup-secret --namespace= --from-literal=access_key= --from-literal=secret_key= @@ -126,6 +128,7 @@ ceph: {} s3: {} # region: "" # bucket: "" + # prefix: "" # secretName is the name of the secret which stores s3 object store access key and secret key # This is not necessary on AWS. Instead you should be able to get the credentials from the EKS service IAM role. # You can create the secret by: