diff options
Diffstat (limited to 'internal/backup')
-rw-r--r-- | internal/backup/backup.go | 8 | ||||
-rw-r--r-- | internal/backup/backup_test.go | 1 |
2 files changed, 5 insertions, 4 deletions
diff --git a/internal/backup/backup.go b/internal/backup/backup.go index a15f47abe..bc54cbaf0 100644 --- a/internal/backup/backup.go +++ b/internal/backup/backup.go @@ -335,10 +335,6 @@ func (mgr *Manager) Restore(ctx context.Context, req *RestoreRequest) error { return fmt.Errorf("manager: %w", err) } - if err := repo.Remove(ctx); err != nil { - return fmt.Errorf("manager: %w", err) - } - var backup *Backup if req.BackupID == "" { backup, err = mgr.locator.FindLatest(ctx, req.VanityRepository) @@ -359,6 +355,10 @@ func (mgr *Manager) Restore(ctx context.Context, req *RestoreRequest) error { defaultBranch, defaultBranchKnown := git.ReferenceName(backup.HeadReference).Branch() + if err := repo.Remove(ctx); err != nil { + return fmt.Errorf("manager: %w", err) + } + if err := repo.Create(ctx, hash, defaultBranch); err != nil { return fmt.Errorf("manager: %w", err) } diff --git a/internal/backup/backup_test.go b/internal/backup/backup_test.go index 81e87a33a..96a06fba3 100644 --- a/internal/backup/backup_test.go +++ b/internal/backup/backup_test.go @@ -977,6 +977,7 @@ func TestManager_Restore_specific(t *testing.T) { return repo, nil }, expectedErrAs: backup.ErrSkipped, + expectExists: true, }, { desc: "single incremental", |