RestoreTenant restore specific namespace
(c Cluster, backupPath string, backupId string, incrFrom, backupNum int, fromNamespace uint64)
| 476 | |
| 477 | // RestoreTenant restore specific namespace |
| 478 | func (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 |
| 523 | func WaitForRestore(c Cluster) error { |