Add RegisterLocalSnapshot and GetRemoteSnapshotMetadata methods
Introduce methods to register local snapshots from archives and to download or restore snapshot metadata, improving snapshot management capabilities. Update README with usage examples.
This commit is contained in:
41
README.md
41
README.md
@ -223,6 +223,41 @@ func main() {
|
||||
|
||||
## Advanced Usage
|
||||
|
||||
### Registering a Local Snapshot
|
||||
|
||||
You can register a local snapshot from an existing archive file with a specified UUID:
|
||||
|
||||
```go
|
||||
// Register a local snapshot from an archive file
|
||||
archivePath := "/path/to/your/archive.zip"
|
||||
snapshotID := "custom-uuid-for-snapshot"
|
||||
snapshotName := "My Local Snapshot"
|
||||
|
||||
if err := ag.RegisterLocalSnapshot(ctx, archivePath, snapshotID, snapshotName); err != nil {
|
||||
log.Fatalf("Failed to register local snapshot: %v", err)
|
||||
}
|
||||
```
|
||||
|
||||
### Downloading Only Snapshot Metadata
|
||||
|
||||
You can download only the metadata of a snapshot from a remote server without downloading the actual files:
|
||||
|
||||
```go
|
||||
// Download only the metadata of a snapshot from a remote server
|
||||
remoteAddress := "remote-server:50051"
|
||||
snapshotID := "snapshot-id-to-download"
|
||||
|
||||
if err := ag.GetRemoteSnapshotMetadata(ctx, remoteAddress, snapshotID); err != nil {
|
||||
log.Fatalf("Failed to download snapshot metadata: %v", err)
|
||||
}
|
||||
|
||||
// If you have a local blob but missing metadata, you can restore the metadata
|
||||
// by passing an empty address
|
||||
if err := ag.GetRemoteSnapshotMetadata(ctx, "", snapshotID); err != nil {
|
||||
log.Fatalf("Failed to restore snapshot metadata: %v", err)
|
||||
}
|
||||
```
|
||||
|
||||
### Creating Incremental Snapshots
|
||||
|
||||
You can create incremental snapshots by specifying a parent snapshot ID:
|
||||
@ -294,6 +329,8 @@ The main entry point for the library.
|
||||
- `ConnectRemote(address string) (*grpc.SnapshotClient, error)` - Connect to a remote server
|
||||
- `GetRemoteSnapshotList(ctx context.Context, address string) ([]store.SnapshotInfo, error)` - List snapshots from a remote server
|
||||
- `GetRemoteSnapshot(ctx context.Context, address string, snapshotID string, localParentID string) error` - Download a snapshot from a remote server
|
||||
- `RegisterLocalSnapshot(ctx context.Context, archivePath string, snapshotID string, name string) error` - Register a local snapshot from an archive path with a specified UUID
|
||||
- `GetRemoteSnapshotMetadata(ctx context.Context, address string, snapshotID string) error` - Download only the metadata of a snapshot from a remote server
|
||||
|
||||
### AgateOptions
|
||||
|
||||
@ -304,7 +341,3 @@ Configuration options for the Agate library.
|
||||
- `CloseFunc func() error` - Called before a snapshot is created or restored
|
||||
- `MetadataStore store.MetadataStore` - Implementation of the metadata store
|
||||
- `BlobStore store.BlobStore` - Implementation of the blob store
|
||||
|
||||
## License
|
||||
|
||||
[Add your license information here]
|
Reference in New Issue
Block a user