From deb8b18a1558ddf4f359146b289d5469bef7cc6d Mon Sep 17 00:00:00 2001 From: Derek Su Date: Wed, 10 Jan 2024 08:52:13 +0000 Subject: [PATCH] backup/restore: update arguments due to the changes in apis Longhorn 7581 Signed-off-by: Derek Su --- app/cmd/restore_to_file.go | 3 ++- pkg/backup/main.go | 29 ++++++++++++++++------------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/app/cmd/restore_to_file.go b/app/cmd/restore_to_file.go index 6ff64df88..68b142f65 100644 --- a/app/cmd/restore_to_file.go +++ b/app/cmd/restore_to_file.go @@ -1,6 +1,7 @@ package cmd import ( + "context" "fmt" "os" "path/filepath" @@ -86,7 +87,7 @@ func restore(url string, concurrentLimit int) error { ConcurrentLimit: int32(concurrentLimit), } - if err := backupstore.RestoreDeltaBlockBackup(config); err != nil { + if err := backupstore.RestoreDeltaBlockBackup(context.Background(), config); err != nil { return err } diff --git a/pkg/backup/main.go b/pkg/backup/main.go index ef97447cf..661a6071d 100644 --- a/pkg/backup/main.go +++ b/pkg/backup/main.go @@ -1,6 +1,7 @@ package backup import ( + "context" "encoding/json" "fmt" "os" @@ -169,12 +170,13 @@ func DoBackupRestore(backupURL string, toFile string, concurrentLimit int, resto log.Infof("Start restoring from %v into snapshot %v", backupURL, toFile) - return backupstore.RestoreDeltaBlockBackup(&backupstore.DeltaRestoreConfig{ - BackupURL: backupURL, - DeltaOps: restoreObj, - Filename: toFile, - ConcurrentLimit: int32(concurrentLimit), - }) + return backupstore.RestoreDeltaBlockBackup(context.Background(), + &backupstore.DeltaRestoreConfig{ + BackupURL: backupURL, + DeltaOps: restoreObj, + Filename: toFile, + ConcurrentLimit: int32(concurrentLimit), + }) } func DoBackupRestoreIncrementally(url string, deltaFile string, lastRestored string, concurrentLimit int, restoreObj *replica.RestoreStatus) error { @@ -182,13 +184,14 @@ func DoBackupRestoreIncrementally(url string, deltaFile string, lastRestored str log.Infof("Start incremental restoring from %v into delta file %v", backupURL, deltaFile) - return backupstore.RestoreDeltaBlockBackupIncrementally(&backupstore.DeltaRestoreConfig{ - BackupURL: backupURL, - DeltaOps: restoreObj, - LastBackupName: lastRestored, - Filename: deltaFile, - ConcurrentLimit: int32(concurrentLimit), - }) + return backupstore.RestoreDeltaBlockBackupIncrementally(context.Background(), + &backupstore.DeltaRestoreConfig{ + BackupURL: backupURL, + DeltaOps: restoreObj, + LastBackupName: lastRestored, + Filename: deltaFile, + ConcurrentLimit: int32(concurrentLimit), + }) } func CreateNewSnapshotMetafile(file string) error {