MCPcopy Index your code
hub / github.com/dgraph-io/dgraph / RestoreTenant

Method RestoreTenant

dgraphapi/cluster.go:478–520  ·  view source on GitHub ↗

RestoreTenant restore specific namespace

(c Cluster, backupPath string, backupId string,
	incrFrom, backupNum int, fromNamespace uint64)

Source from the content-addressed store, hash-verified

476
477// RestoreTenant restore specific namespace
478func (hc *HTTPClient) RestoreTenant(c Cluster, backupPath string, backupId string,
479 incrFrom, backupNum int, fromNamespace uint64) error {
480
481 encKey, err := c.GetEncKeyPath()
482 if err != nil {
483 return errors.Wrapf(err, "error getting encryption key path")
484 }
485
486 query := `mutation restoreTenant( $location: String!, $backupId: String,
487 $incrFrom: Int, $backupNum: Int, $encKey: String,$fromNamespace: Int! ) {
488 restoreTenant(input: {restoreInput: { location: $location, backupId: $backupId,
489 incrementalFrom: $incrFrom, backupNum: $backupNum,
490 encryptionKeyFile: $encKey },fromNamespace:$fromNamespace}) {
491 code
492 message
493 }
494 }`
495 vars := map[string]interface{}{"location": backupPath, "backupId": backupId, "backupNum": backupNum,
496 "encKey": encKey, "fromNamespace": fromNamespace, "incrFrom": incrFrom}
497
498 params := GraphQLParams{
499 Query: query,
500 Variables: vars,
501 }
502 resp, err := hc.RunGraphqlQuery(params, true)
503 if err != nil {
504 return err
505 }
506
507 var restoreResp struct {
508 RestoreTenant struct {
509 Code string
510 Message string
511 }
512 }
513 if err := json.Unmarshal(resp, &restoreResp); err != nil {
514 return errors.Wrap(err, "error unmarshalling restore response")
515 }
516 if restoreResp.RestoreTenant.Code != "Success" {
517 return fmt.Errorf("restoreTenant failed, response: %+v", restoreResp.RestoreTenant)
518 }
519 return nil
520}
521
522// WaitForRestore waits for restore to complete on all alphas
523func WaitForRestore(c Cluster) error {

Callers 2

commonTestFunction · 0.80
commonIncRestoreTestFunction · 0.80

Calls 3

RunGraphqlQueryMethod · 0.95
GetEncKeyPathMethod · 0.65
ErrorfMethod · 0.45

Tested by 2

commonTestFunction · 0.64
commonIncRestoreTestFunction · 0.64