diff --git a/graphql/admin/endpoints_ee.go b/graphql/admin/endpoints_ee.go index e1392ae4329..210c0501b0a 100644 --- a/graphql/admin/endpoints_ee.go +++ b/graphql/admin/endpoints_ee.go @@ -63,6 +63,11 @@ const adminTypes = ` """ location: String! + """ + Backup ID of the backup series to restore. This ID is included in the manifest.json file. + """ + backupId: String! + """ Access key credential for the destination. """ diff --git a/graphql/admin/restore.go b/graphql/admin/restore.go index 3153e5480b0..8895a0380f5 100644 --- a/graphql/admin/restore.go +++ b/graphql/admin/restore.go @@ -35,6 +35,7 @@ type restoreResolver struct { type restoreInput struct { Location string + BackupId string AccessKey string SecretKey string SessionToken string @@ -52,6 +53,7 @@ func (rr *restoreResolver) Rewrite( req := pb.RestoreRequest{ Location: input.Location, + BackupId: input.BackupId, AccessKey: input.AccessKey, SecretKey: input.SecretKey, SessionToken: input.SessionToken, diff --git a/systest/online-restore/online_restore_test.go b/systest/online-restore/online_restore_test.go index 8d6f0d57e12..bac29320ed9 100644 --- a/systest/online-restore/online_restore_test.go +++ b/systest/online-restore/online_restore_test.go @@ -37,7 +37,7 @@ import ( func sendRestoreRequest(t *testing.T) { restoreRequest := `mutation restore() { - restore(input: {location: "/data/alpha1/backup"}) { + restore(input: {location: "/data/alpha1/backup", backupId: "compassionate_antonelli7"}) { response { code message @@ -135,3 +135,27 @@ func TestBasicRestore(t *testing.T) { runQueries(t, dg) runMutations(t, dg) } + +func TestInvalidBackupId(t *testing.T) { + restoreRequest := `mutation restore() { + restore(input: {location: "/data/alpha1/backup", backupId: "bad-backup-id"}) { + response { + code + message + } + } + }` + + adminUrl := "http://localhost:8180/admin" + params := testutil.GraphQLParams{ + Query: restoreRequest, + } + b, err := json.Marshal(params) + require.NoError(t, err) + + resp, err := http.Post(adminUrl, "application/json", bytes.NewBuffer(b)) + require.NoError(t, err) + buf, err := ioutil.ReadAll(resp.Body) + require.NoError(t, err) + require.Contains(t, string(buf), "failed to verify backup") +}