From 55e0220d466e4f93ab85582e068068600e967c2c Mon Sep 17 00:00:00 2001 From: rainzm Date: Tue, 25 Jan 2022 17:05:06 +0800 Subject: [PATCH 1/2] fix(host): init local backup dir --- pkg/hostman/storageman/storage_local.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkg/hostman/storageman/storage_local.go b/pkg/hostman/storageman/storage_local.go index 16025a3a02..1c42ba7b4e 100644 --- a/pkg/hostman/storageman/storage_local.go +++ b/pkg/hostman/storageman/storage_local.go @@ -102,6 +102,13 @@ func (s *SLocalStorage) SyncStorageSize() error { } func (s *SLocalStorage) CreateDiskFromBackup(ctx context.Context, disk IDisk, input *SDiskCreateByDiskinfo) error { info := input.DiskInfo + backupDir := s.GetBackupDir() + if !fileutils2.Exists(backupDir) { + output, err := procutils.NewCommand("mkdir", "-p", backupDir).Output() + if err != nil { + return errors.Wrapf(err, "mkdir %s failed: %s", backupDir, output) + } + } backupPath := path.Join(s.GetBackupDir(), info.Backup.BackupId) if !fileutils2.Exists(backupPath) { _, err := s.storageBackupRecovery(ctx, &SStorageBackup{ From 8d684d3758f482b7c44a6f78c056785278207c32 Mon Sep 17 00:00:00 2001 From: rainzm Date: Tue, 25 Jan 2022 17:51:17 +0800 Subject: [PATCH 2/2] fix(region): marshall correctly SDiskBackup.DiskConfig --- pkg/compute/models/backup.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/compute/models/backup.go b/pkg/compute/models/backup.go index 72b7be79f1..e2c3185f0b 100644 --- a/pkg/compute/models/backup.go +++ b/pkg/compute/models/backup.go @@ -58,8 +58,8 @@ type SDiskBackup struct { DiskSizeMb int `nullable:"false" list:"user" create:"optional"` DiskType string `width:"32" charset:"ascii" nullable:"true" list:"user" create:"optional"` // 操作系统类型 - OsType string `width:"32" charset:"ascii" nullable:"true" list:"user" create:"optional"` - DiskConfig *SBackupDiskConfig `ignore:"true"` + OsType string `width:"32" charset:"ascii" nullable:"true" list:"user" create:"optional"` + DiskConfig *SBackupDiskConfig } var DiskBackupManager *SDiskBackupManager