You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## Problem
Backups/Restore are a part of the `2025-04` spec and need to be
implemented in the Go client.
## Solution
Add new types for working with `Backups` and `RestoreJob` methods on
`Client`:
- `Backup`
- `BackupList`
- `RestoreJob`
- `RestoreJobList`
- `CreateBackupParams`
- `CreateIndexFromBackupParams`
- `CreateIndexFromBackupResponse`
- `ListBackupsParams`
- `ListRestoreJobsParams`
Add new methods for working with backups as a part of `Client`:
- `CreateBackup`
- `CreateIndexFromBackup`
- `DescribeBackup`
- `DeleteBackup`
- `DescribeRestoreJob`
- `ListBackups`
- `ListRestoreJobs`
## Type of Change
- [ ] Bug fix (non-breaking change which fixes an issue)
- [X] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] This change requires a documentation update
- [ ] Infrastructure change (CI configs, etc)
- [ ] Non-code change (docs, etc)
- [ ] None of the above: (explain here)
## Test Plan
CI - unit & integration tests
New integration tests have been added to validate the create backup ->
list/describe backups -> create index from backup -> list/describe
restore jobs flow.
You can also test using the `README` or the integration tests themselves
as example code:
```go
package main
import (
"context"
"fmt"
"log"
"os"
"time"
"github.com/pinecone-io/go-pinecone/v3/pinecone"
)
ctx := context.Background()
clientParams := pinecone.NewClientParams{
ApiKey: os.Getenv("PINECONE_API_KEY"),
}
pc, err := pinecone.NewClient(clientParams)
if err != nil {
log.Fatalf("Failed to create Client: %w", err)
}
indexName := "my-index"
backupName := fmt.Sprintf("backup-%s", )
backupDesc := fmt.Sprintf("Backup created for index %s", indexName)
fmt.Printf("Creating backup: %s for index: %s\n", backupName, indexName)
backup, err := pc.CreateBackup(ctx, &pinecone.CreateBackupParams{
IndexName: indexName,
Name: &backupName,
Description: &backupDesc,
})
if err != nil {
log.Fatalf("Failed to create backup: %w", err)
}
backup, err = pc.DescribeBackup(ctx, backup.BackupId)
if err != nil {
log.Fatalf("Failed to describe backup: %w", err)
}
// wait for backup to be "Complete" before triggering a restore job
log.Printf("Backup status: %v", backup.Status)
limit := 10
backups, err := pc.ListBackups(ctx, &pinecone.ListBackupsParams{
Limit: &limit,
IndexName: &indexName,
})
if err != nil {
log.Fatalf("Failed to list backups: %w", err)
}
// create a new serverless index from the backup
restoredIndexName := indexName + "-from-backup"
restoredIndexTags := IndexTags{"restored_on": time.Now().Format("2006-01-02 15:04")}
createIndexFromBackupResp, err := pc.CreateIndexFromBackup(context.Background(), &CreateIndexFromBackupParams{
BackupId: ts.backupId,
Name: restoredIndexName,
Tags: &restoredIndexTags,
})
// check the status of the index restoration
restoreJob, err := pc.DescribeRestoreJob(ctx, restoreJob.RestoreJobId)
if err != nil {
log.Fatalf("Failed to describe restore job: %w", err)
}
```
---
- To see the specific tasks where the Asana app for GitHub is being
used, see below:
- https://app.asana.com/0/0/1209571416750587
Copy file name to clipboardExpand all lines: README.md
+63Lines changed: 63 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1630,6 +1630,69 @@ func main() {
1630
1630
}
1631
1631
```
1632
1632
1633
+
## Backups
1634
+
1635
+
A backup is a static copy of a serverless index that only consumes storage. It is a non-queryable representation of a set of records. You can create a backup of a serverless index, and you can create a new serverless index from a backup. You can optionally apply new `Tags` and `DeletionProtection` configurations for the index when calling `CreateIndexFromBackup`. You can read more about [backups here](https://docs.pinecone.io/guides/manage-data/backups-overview).
1636
+
1637
+
```go
1638
+
ctx:= context.Background()
1639
+
1640
+
clientParams:= pinecone.NewClientParams{
1641
+
ApiKey: os.Getenv("PINECONE_API_KEY"),
1642
+
}
1643
+
1644
+
pc, err:= pinecone.NewClient(clientParams)
1645
+
if err != nil {
1646
+
log.Fatalf("Failed to create Client: %w", err)
1647
+
}
1648
+
1649
+
indexName:="my-index"
1650
+
backupName:= fmt.Sprintf("backup-%s", )
1651
+
backupDesc:= fmt.Sprintf("Backup created for index %s", indexName)
1652
+
fmt.Printf("Creating backup: %s for index: %s\n", backupName, indexName)
log.Fatalf("Failed to describe restore job: %w", err)
1693
+
}
1694
+
```
1695
+
1633
1696
## Inference
1634
1697
1635
1698
The `Client` object has an `Inference` namespace which exposes an `InferenceService` pointer which allows interacting with Pinecone's [Inference API](https://docs.pinecone.io/guides/inference/generate-embeddings).
0 commit comments