Skip to content

Commit

Permalink
fix(restore): allow incrementalFrom to be 1 in restore API (#8988)
Browse files Browse the repository at this point in the history
This is a minor inconvenience while using the incremental restore API
that when incrementalFrom is set to 1, we throw an error back. The
restore API takes two backup numbers incrementalFrom & backupNum and
restores all the backups including both the ends, i.e. following set
notation all the backups in the set [incrementalFrom, backupNum] are
restored. This should work fine when incrementalFrom is set to 1 which
is a full backup.
  • Loading branch information
mangalaman93 committed Nov 27, 2023
1 parent 6357cb4 commit eb59d12
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 0 additions & 3 deletions systest/integration2/incremental_restore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,6 @@ func TestIncrementalRestore(t *testing.T) {
t.Logf("restoring backup #%v\n", i)

incrFrom := i - 1
if i == 2 {
incrFrom = 0
}
require.NoError(t, hc.Restore(c, dgraphtest.DefaultBackupDir, "", incrFrom, i))
require.NoError(t, dgraphtest.WaitForRestore(c))

Expand Down
8 changes: 7 additions & 1 deletion worker/online_restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,14 @@ func handleRestoreProposal(ctx context.Context, req *pb.RestoreRequest, pidx uin
return errors.Errorf("nil restore request")
}

// This is a minor inconvenience while using the incremental restore API that
// when incrementalFrom is set to 1, we throw an error back. The restore API
// takes two backup numbers incrementalFrom & backupNum and restores all the
// backups including both the ends, i.e. following set notation all the backups
// in the set [incrementalFrom, backupNum] are restored. This should work fine
// when incrementalFrom is set to 1 which is a full backup.
if req.IncrementalFrom == 1 {
return errors.Errorf("Incremental restore must not include full backup")
req.IncrementalFrom = 0
}

// Clean up the cluster if it is a full backup restore.
Expand Down

0 comments on commit eb59d12

Please sign in to comment.