Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrEncryptionKeyNotProvided = errors.New("encryption key not provided") ErrBackupEncryptionKeyNotProvided = errors.New("backup encryption key not provided") )
Functions ¶
func NewBadgerBackupExecutor ¶
func NewBadgerBackupExecutor( nodeID string, db *badger.DB, backupEncryptionKey []byte, backupDir string, uploader ...BackupUploader, ) *badgerBackupExecutor
NewBadgerBackupExecutor creates a new backup executor.
Types ¶
type BackupUploader ¶
BackupUploader is an optional interface for pushing encrypted backup files to remote storage.
type BadgerBackupMeta ¶
type BadgerConfig ¶
type BadgerKVStore ¶
BadgerKVStore is an implementation of the KVStore interface using BadgerDB.
func NewBadgerKVStore ¶
func NewBadgerKVStore(config BadgerConfig) (*BadgerKVStore, error)
NewBadgerKVStore creates a new BadgerKVStore instance.
func (*BadgerKVStore) Backup ¶
func (b *BadgerKVStore) Backup() error
func (*BadgerKVStore) Delete ¶
func (b *BadgerKVStore) Delete(key string) error
Delete removes a key-value pair from BadgerDB.
func (*BadgerKVStore) Get ¶
func (b *BadgerKVStore) Get(key string) ([]byte, error)
Get retrieves the value associated with a key from BadgerDB.
func (*BadgerKVStore) Keys ¶
func (b *BadgerKVStore) Keys() ([]string, error)
type KVStore ¶
type KVStore interface {
// Put stores a key-value pair in the store.
Put(key string, value []byte) error
// Get retrieves the value associated with a key. If the key is not found, it returns an empty slice.
Get(key string) ([]byte, error)
// Delete removes a key-value pair from the store.
Delete(key string) error
// Close closes the key-value store.
Close() error
Backup() error
}
KVStore defines the interface for a key-value store.
type R2Uploader ¶
type R2Uploader struct {
// contains filtered or unexported fields
}
R2Uploader uploads encrypted backup files to Cloudflare R2 using the S3-compatible API.
func NewR2Uploader ¶
func NewR2Uploader(accountID, accessKeyID, secretAccessKey, bucket, prefix string) (*R2Uploader, error)
NewR2Uploader creates an R2Uploader.
- accountID: Cloudflare account ID (used to build the endpoint URL)
- accessKeyID / secretAccessKey: R2 API token credentials
- bucket: R2 bucket name
- prefix: optional object key prefix (e.g. "node0/"); leave empty for root
func (*R2Uploader) Download ¶
Download retrieves a single object by its full key and returns its contents.
func (*R2Uploader) ListObjects ¶
func (u *R2Uploader) ListObjects(ctx context.Context) ([]string, error)
ListObjects returns all object keys under the uploader's prefix, sorted ascending.