backup

package
v0.11.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 16, 2026 License: MIT Imports: 15 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// BackupVersion is the current backup format version
	BackupVersion = "1.0.0"

	// BackupExtension is the file extension for backup files
	BackupExtension = ".weavebak"

	// CompressedExtension is the additional extension for compressed backups
	CompressedExtension = ".gz"
)

Variables

This section is empty.

Functions

func WriteBackup

func WriteBackup(backup *BackupFormat, outputPath string, compress bool) error

WriteBackup writes a backup to a file with optional compression

Types

type BackupDocument

type BackupDocument struct {
	ID        string                 `json:"id"`
	Content   string                 `json:"content,omitempty"`
	Text      string                 `json:"text,omitempty"`
	Embedding []float64              `json:"embedding"`
	Metadata  map[string]interface{} `json:"metadata,omitempty"`

	// Image-specific fields
	Image     string `json:"image,omitempty"`
	ImageData string `json:"image_data,omitempty"`
	URL       string `json:"url,omitempty"`

	// External storage fields (v0.10.0+)
	ImageThumbnail string                 `json:"image_thumbnail,omitempty"`
	ImageURL       string                 `json:"image_url,omitempty"`
	ImageMetadata  map[string]interface{} `json:"image_metadata,omitempty"`
}

BackupDocument represents a single document in the backup

type BackupFormat

type BackupFormat struct {
	Version   string           `json:"version"`
	Metadata  BackupMetadata   `json:"metadata"`
	Schema    BackupSchema     `json:"schema,omitempty"`
	Documents []BackupDocument `json:"documents"`
}

BackupFormat represents the structure of a .weavebak backup file

func NewBackupFormat

func NewBackupFormat(collection string, vdbType string, embeddingModel string, vectorDims int) *BackupFormat

NewBackupFormat creates a new backup format with current version and metadata

func ReadBackup

func ReadBackup(inputPath string) (*BackupFormat, error)

ReadBackup reads a backup from a file (auto-detects compression)

type BackupInfo

type BackupInfo struct {
	FilePath        string
	FileName        string
	Collection      string
	VDBType         string
	TotalDocuments  int
	BackupSizeBytes int64
	CreatedAt       time.Time
	WeaveVersion    string
	Compressed      bool
}

BackupInfo holds information about a backup file

type BackupMetadata

type BackupMetadata struct {
	Collection       string    `json:"collection"`
	VDBType          string    `json:"vdb_type"`
	EmbeddingModel   string    `json:"embedding_model"`
	VectorDimensions int       `json:"vector_dimensions"`
	CreatedAt        time.Time `json:"created_at"`
	WeaveVersion     string    `json:"weave_version"`
	TotalDocuments   int       `json:"total_documents"`
	BackupSizeBytes  int64     `json:"backup_size_bytes"`
}

BackupMetadata contains metadata about the backup

type BackupSchema

type BackupSchema struct {
	VectorDimensions int           `json:"vector_dimensions"`
	SimilarityMetric string        `json:"similarity_metric,omitempty"`
	Fields           []SchemaField `json:"fields,omitempty"`
}

BackupSchema contains the collection schema

type CreateOptions

type CreateOptions struct {
	Collection string
	OutputFile string
	VDBType    string
	Compress   bool
	BatchSize  int
	Quiet      bool
}

CreateOptions holds options for backup creation

type RemoteStorage added in v0.11.5

type RemoteStorage struct {
	// contains filtered or unexported fields
}

RemoteStorage handles backup uploads/downloads to S3/MinIO

func NewRemoteStorage added in v0.11.5

func NewRemoteStorage(cfg *RemoteStorageConfig) (*RemoteStorage, error)

NewRemoteStorage creates a new remote storage client

func (*RemoteStorage) Delete added in v0.11.5

func (r *RemoteStorage) Delete(ctx context.Context, key string) error

Delete deletes a backup from remote storage

func (*RemoteStorage) Download added in v0.11.5

func (r *RemoteStorage) Download(ctx context.Context, key string) ([]byte, error)

Download downloads a backup from remote storage

func (*RemoteStorage) DownloadStream added in v0.11.5

func (r *RemoteStorage) DownloadStream(ctx context.Context, key string) (io.ReadCloser, error)

DownloadStream downloads a backup and returns a reader

func (*RemoteStorage) Exists added in v0.11.5

func (r *RemoteStorage) Exists(ctx context.Context, key string) (bool, error)

Exists checks if a backup exists in remote storage

func (*RemoteStorage) List added in v0.11.5

func (r *RemoteStorage) List(ctx context.Context, prefix string) ([]string, error)

List lists backups in remote storage with optional prefix

func (*RemoteStorage) Upload added in v0.11.5

func (r *RemoteStorage) Upload(ctx context.Context, key string, data []byte) error

Upload uploads a backup to remote storage

func (*RemoteStorage) UploadStream added in v0.11.5

func (r *RemoteStorage) UploadStream(ctx context.Context, key string, reader io.Reader) error

UploadStream uploads a backup from a reader

type RemoteStorageConfig added in v0.11.5

type RemoteStorageConfig struct {
	// Type: "s3" or "minio"
	Type string

	// S3/MinIO endpoint (MinIO only, S3 uses region-based endpoints)
	Endpoint string

	// AWS Region (required for S3, optional for MinIO)
	Region string

	// S3 Bucket name
	Bucket string

	// Access credentials
	AccessKeyID     string
	SecretAccessKey string

	// Use SSL/TLS (default: true for S3, false for MinIO)
	UseSSL bool

	// Optional path prefix within bucket (e.g., "backups/")
	PathPrefix string
}

RemoteStorageConfig holds configuration for remote storage backends

type RestoreOptions

type RestoreOptions struct {
	BackupFile string
	Collection string // Optional: override collection name
	VDBType    string
	Overwrite  bool
	Quiet      bool
}

RestoreOptions holds options for backup restoration

type SchemaField

type SchemaField struct {
	Name string `json:"name"`
	Type string `json:"type"`
}

SchemaField represents a field in the collection schema

type ValidationResult

type ValidationResult struct {
	Valid           bool
	Version         string
	Collection      string
	TotalDocuments  int
	BackupSizeBytes int64
	Errors          []string
	Warnings        []string
}

ValidationResult holds the result of backup validation

func ValidateBackup

func ValidateBackup(inputPath string) (*ValidationResult, error)

ValidateBackup validates a backup file

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL