mirror of
https://github.com/rancher/rke.git
synced 2025-08-15 13:34:36 +00:00
Allow local backup for rancher
This commit is contained in:
parent
82fa8d6305
commit
cf037b1ed6
@ -130,14 +130,13 @@ func validateServicesOptions(c *Cluster) error {
|
|||||||
|
|
||||||
func validateEtcdBackupOptions(c *Cluster) error {
|
func validateEtcdBackupOptions(c *Cluster) error {
|
||||||
if c.Services.Etcd.BackupConfig != nil {
|
if c.Services.Etcd.BackupConfig != nil {
|
||||||
if c.Services.Etcd.BackupConfig.S3BackupConfig == nil {
|
if c.Services.Etcd.BackupConfig.S3BackupConfig != nil {
|
||||||
return fmt.Errorf("etcd backup is enabled but no s3 backend is specified")
|
if len(c.Services.Etcd.BackupConfig.S3BackupConfig.Endpoint) == 0 {
|
||||||
}
|
return fmt.Errorf("etcd s3 backup backend endpoint can't be empty")
|
||||||
if len(c.Services.Etcd.BackupConfig.S3BackupConfig.Endpoint) == 0 {
|
}
|
||||||
return fmt.Errorf("etcd s3 backup backend endpoint can't be empty")
|
if len(c.Services.Etcd.BackupConfig.S3BackupConfig.BucketName) == 0 {
|
||||||
}
|
return fmt.Errorf("etcd s3 backup backend bucketName can't be empty")
|
||||||
if len(c.Services.Etcd.BackupConfig.S3BackupConfig.BucketName) == 0 {
|
}
|
||||||
return fmt.Errorf("etcd s3 backup backend bucketName can't be empty")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -275,7 +275,7 @@ func RunEtcdSnapshotSave(ctx context.Context, etcdHost *hosts.Host, prsMap map[s
|
|||||||
imageCfg.Cmd = append(imageCfg.Cmd, "--creation="+es.Creation)
|
imageCfg.Cmd = append(imageCfg.Cmd, "--creation="+es.Creation)
|
||||||
}
|
}
|
||||||
|
|
||||||
if es.BackupConfig != nil && es.BackupConfig.S3BackupConfig != nil {
|
if es.BackupConfig != nil {
|
||||||
imageCfg = configS3BackupImgCmd(ctx, imageCfg, es.BackupConfig)
|
imageCfg = configS3BackupImgCmd(ctx, imageCfg, es.BackupConfig)
|
||||||
}
|
}
|
||||||
hostCfg := &container.HostConfig{
|
hostCfg := &container.HostConfig{
|
||||||
@ -447,17 +447,21 @@ func GetEtcdSnapshotChecksum(ctx context.Context, etcdHost *hosts.Host, prsMap m
|
|||||||
}
|
}
|
||||||
|
|
||||||
func configS3BackupImgCmd(ctx context.Context, imageCfg *container.Config, bc *v3.BackupConfig) *container.Config {
|
func configS3BackupImgCmd(ctx context.Context, imageCfg *container.Config, bc *v3.BackupConfig) *container.Config {
|
||||||
log.Infof(ctx, "Invoking s3 backup server cmd config, bucketName:%s, endpoint:%s", bc.S3BackupConfig.BucketName, bc.S3BackupConfig.Endpoint)
|
|
||||||
cmd := []string{
|
cmd := []string{
|
||||||
"--s3-backup=true",
|
|
||||||
"--s3-endpoint=" + bc.S3BackupConfig.Endpoint,
|
|
||||||
"--s3-accessKey=" + bc.S3BackupConfig.AccessKey,
|
|
||||||
"--s3-secretKey=" + bc.S3BackupConfig.SecretKey,
|
|
||||||
"--s3-bucketName=" + bc.S3BackupConfig.BucketName,
|
|
||||||
"--s3-region=" + bc.S3BackupConfig.Region,
|
|
||||||
"--creation=" + fmt.Sprintf("%dh", bc.IntervalHours),
|
"--creation=" + fmt.Sprintf("%dh", bc.IntervalHours),
|
||||||
"--retention=" + fmt.Sprintf("%dh", bc.Retention*bc.IntervalHours),
|
"--retention=" + fmt.Sprintf("%dh", bc.Retention*bc.IntervalHours),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if bc.S3BackupConfig != nil {
|
||||||
|
cmd = append(cmd, []string{
|
||||||
|
"--s3-backup=true",
|
||||||
|
"--s3-endpoint=" + bc.S3BackupConfig.Endpoint,
|
||||||
|
"--s3-accessKey=" + bc.S3BackupConfig.AccessKey,
|
||||||
|
"--s3-secretKey=" + bc.S3BackupConfig.SecretKey,
|
||||||
|
"--s3-bucketName=" + bc.S3BackupConfig.BucketName,
|
||||||
|
"--s3-region=" + bc.S3BackupConfig.Region,
|
||||||
|
}...)
|
||||||
|
}
|
||||||
imageCfg.Cmd = append(imageCfg.Cmd, cmd...)
|
imageCfg.Cmd = append(imageCfg.Cmd, cmd...)
|
||||||
return imageCfg
|
return imageCfg
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user