Merge pull request #2038 from liuxu623/master

fix: backup script doesn't work when set etcd dataDir to another dir except '/var/lib/etcd'
This commit is contained in:
KubeSphere CI Bot 2023-11-14 09:56:27 +08:00 committed by GitHub
commit b56826b4bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 0 deletions

View File

@ -406,6 +406,7 @@ func (b *BackupETCD) Execute(runtime connector.Runtime) error {
Data: util.Data{
"Hostname": runtime.RemoteHost().GetName(),
"Etcdendpoint": fmt.Sprintf("https://%s:2379", runtime.RemoteHost().GetInternalAddress()),
"DataDir": b.KubeConf.Cluster.Etcd.DataDir,
"Backupdir": b.KubeConf.Cluster.Etcd.BackupDir,
"KeepbackupNumber": b.KubeConf.Cluster.Etcd.KeepBackupNumber + 1,
"EtcdBackupScriptDir": b.KubeConf.Cluster.Etcd.BackupScriptDir,

View File

@ -32,7 +32,11 @@ set -o pipefail
ETCDCTL_PATH='/usr/local/bin/etcdctl'
ENDPOINTS='{{ .Etcdendpoint }}'
{{- if .DataDir }}
ETCD_DATA_DIR="{{ .DataDir }}"
{{- else }}
ETCD_DATA_DIR="/var/lib/etcd"
{{- end }}
BACKUP_DIR="{{ .Backupdir }}/etcd-$(date +%Y-%m-%d-%H-%M-%S)"
KEEPBACKUPNUMBER='{{ .KeepbackupNumber }}'
ETCDBACKUPSCIPT='{{ .EtcdBackupScriptDir }}'