Skip to content

Conversation

@rohanshah18
Copy link
Contributor

@rohanshah18 rohanshah18 commented Apr 30, 2025

Problem

Add support for backups and restore.

Solution

Added support for backups and restore.

Following methods were added for Backups:

  1. createBackup(String indexName, String backupName, String description)
  2. listIndexBackups(String indexName)
  3. listIndexBackups(String indexName, Integer limit, String paginationToken)
  4. listProjectBackups()
  5. describeBackup(String backupId)
  6. deleteBackup(String backupId)
  7. createIndexFromBackup(String backupId,
    String indexName,
    Map<String, String> tags,
    DeletionProtection deletionProtection)
  8. createIndexFromBackup(String backupId, String indexName)

Following methods were added for Restore:

  1. describeRestoreJob(String jobId)
  2. listRestoreJobs(Integer limit)
  3. listRestoreJobs(String paginationToken)
  4. listRestoreJobs(Integer limit, String paginationToken)

Following code exactly shows all of the methods added for backup and restore for a serverless index.

import io.pinecone.clients.Pinecone;
import org.openapitools.db_control.client.ApiException;
import org.openapitools.db_control.client.model.*;

public class restoreAndBackups {
    public static void main(String[] args) throws ApiException, InterruptedException {
        Pinecone pinecone = new Pinecone.Builder("PINECONE_API_KEY").build();

        String indexName1 = "test-index-1";
        String indexName2 = "test-index-2";

        // create a backup from index
        BackupModel backupModel1 = pinecone.createBackup(indexName1, "backup-id-1", "description-for-backup-1");
        System.out.println("backupModel1: " + backupModel1);

        BackupModel backupModel2 = pinecone.createBackup(indexName2, "backup-id-2", "description-for-backup-2");
        System.out.println("backupModel2: " + backupModel2);

        // list all backups for an index
        BackupList backupList = pinecone.listIndexBackups(indexName1);
        System.out.println("backupList for index1: " + backupList);

        // list all backups for a project
        backupList = pinecone.listProjectBackups();
        System.out.println("backupList for project: " + backupList);

        // describe backup
        backupModel1 = pinecone.describeBackup(backupModel1.getBackupId());
        System.out.println("describe backup for index1: " + backupModel1);

        backupModel2 = pinecone.describeBackup(backupModel2.getBackupId());
        System.out.println("describe backup index2: " + backupModel2);

        // delete backup
        pinecone.deleteBackup(backupModel1.getBackupId());

        // wait for the backup to be ready
        Thread.sleep(10000);

        // create index from a backup
        CreateIndexFromBackupResponse backupResponse = pinecone.createIndexFromBackup(backupModel1.getBackupId(), "test-index-3");
        System.out.println(backupResponse.getRestoreJobId());

        // wait for index to be created
        Thread.sleep(5000);

        // describeRestoreJob
        RestoreJobModel restoreJobModel = pinecone.describeRestoreJob(backupResponse.getRestoreJobId());
        System.out.println("restore model: " + restoreJobModel);

        // listRestoreJobs
        RestoreJobList restoreJobList = pinecone.listRestoreJobs(2);
        System.out.println("restore job list: " + restoreJobList);
    }
}

Type of Change

  • New feature (non-breaking change which adds functionality)

Test Plan

Manually tested backups and restore by running the sample code above.

@rohanshah18 rohanshah18 marked this pull request as ready for review April 30, 2025 19:10
Copy link
Contributor

@austin-denoble austin-denoble left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this LGTM, left a couple comments on some nit details. Appreciate the manual testing steps, I'll try to get to those myself.

@austin-denoble
Copy link
Contributor

It might be nice to add your usage example from the PR to the README since there aren't any tests or examples to demonstrate how to use the feature directly.

@rohanshah18 rohanshah18 merged commit f689641 into rshah/release-candidate/2025-04 May 2, 2025
5 of 7 checks passed
@rohanshah18 rohanshah18 deleted the rshah/backup-restore branch May 2, 2025 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants