Documentation
¶
Overview ¶
Package backup publishes coordinated authority, namespace and placement checkpoints to an independent backend and restores them only while offline.
Index ¶
- Constants
- type CaptureConfig
- type Checkpoint
- type Header
- type Hooks
- type Image
- type Info
- type Manifest
- type Namespace
- type NamespaceRestoreOptions
- type ObjectRoot
- type RestoreOptions
- type Restored
- type Source
- type SourceFunc
- type Store
- func (s Store) Create(ctx context.Context, source Source) (created Info, result error)
- func (s Store) CreateNamespace(ctx context.Context, source Source, namespaceID string) (Info, error)
- func (s Store) InspectCurrent(ctx context.Context, namespace, placement, authority string) (Checkpoint, error)
- func (s Store) List(ctx context.Context) ([]Info, error)
- func (s Store) Load(ctx context.Context, key string) (Info, error)
- func (s Store) Prune(ctx context.Context) error
- func (s Store) Restore(ctx context.Context, key, destination string, options RestoreOptions) (Restored, error)
- func (s Store) RestoreNamespace(ctx context.Context, key, destination string, options NamespaceRestoreOptions) (Restored, error)
Constants ¶
const DefaultPrefix = "cluster/backups"
const NamespaceVersion = 2
const SingleNamespaceVersion = 3
const Version = 1
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CaptureConfig ¶
type CaptureConfig struct {
Authority *clustermeta.Authority
Namespace meta.Snapshotter
Placement *clusterstore.Store
VolumeID string
Format fsformat.Volume
Namespaces []Namespace
}
CaptureConfig captures three images at one authority barrier. The caller must already hold the shared file server's quiesce gate and have completed backend drain. Wrap this in SourceFunc to acquire that outer gate, returning before Store.Create uploads any image to the backup backend.
func (CaptureConfig) Capture ¶
func (c CaptureConfig) Capture(ctx context.Context, directory string) (checkpoint Checkpoint, err error)
type Checkpoint ¶
type Checkpoint struct {
Header Header
NamespacePath string
PlacementPath string
AuthorityPath string
}
Checkpoint paths belong to the private directory supplied to Capture. The source must freeze mutations, drain backend writes, cross the authority barrier and capture all three images at Header.Sequence before returning.
type Header ¶
type Header struct {
ClusterID string `json:"cluster_id"`
VolumeID string `json:"volume_id"`
Incarnation string `json:"incarnation"`
Epoch uint64 `json:"epoch"`
Sequence uint64 `json:"sequence"`
HeadHash string `json:"head_hash"`
DomainApplied map[string]uint64 `json:"domain_applied"`
Format fsformat.Volume `json:"format"`
Namespaces []Namespace `json:"namespaces,omitempty"`
Scope *Namespace `json:"scope,omitempty"`
ProtectionID string `json:"protection_id,omitempty"`
}
type Hooks ¶
type Hooks struct {
BeforePublish func(context.Context, Info) error
AfterPrune func(context.Context, Info) error
Finish func(context.Context, string, bool) error
}
Hooks borrows the caller's metadata protection lifecycle. BeforePublish must durably bind Info to its protection before the manifest can become visible. AfterPrune runs only after exact manifest absence and image deletion are confirmed. Finish ends process-local upload activity; published is true only if the manifest upload returned success, independently of retention errors. A failed/unknown upload must never cause Finish to discard its object roots.
type Namespace ¶
type Namespace struct {
Name string `json:"name"`
ID string `json:"id"`
VolumeID string `json:"volume_id"`
Format fsformat.Volume `json:"format"`
}
Namespace identifies one independently scoped volume in the shared image. Empty Name/ID is the default namespace; root is only its external alias.
type NamespaceRestoreOptions ¶
type NamespaceRestoreOptions struct {
// Current is an immutable checkpoint of the current cluster, not the old
// backup being restored. The caller must stop all exports/Meta and hold the
// source writer lock until this method returns.
Current Checkpoint
Authority clustermeta.RestoreOptions
VerifyObject func(context.Context, ObjectRoot) error
// MaxMutationBytes bounds the complete in-memory restore WAL batch.
MaxMutationBytes int
}
type ObjectRoot ¶
type ObjectRoot struct {
Key string `json:"key"`
Record clusterstore.Record `json:"record"`
}
type RestoreOptions ¶
type RestoreOptions struct {
Authority clustermeta.RestoreOptions
// VerifyObject must fetch and verify each complete encoded object using the
// manifest's descriptor/replicas, not the lost online placement index.
VerifyObject func(context.Context, ObjectRoot) error
// MaxMutationBytes bounds the offline suffix which drops unreferenced index rows.
MaxMutationBytes int
}
type Source ¶
type Source interface {
Capture(context.Context, string) (Checkpoint, error)
}
func NamespaceSource ¶
NamespaceSource filters an already coordinated checkpoint before upload. The underlying Source must quiesce files, drain backend and cross the authority barrier exactly as for full backups. Full intermediate images stay private and are removed with the caller's checkpoint temporary directory.
type SourceFunc ¶
type SourceFunc func(context.Context, string) (Checkpoint, error)
func (SourceFunc) Capture ¶
func (f SourceFunc) Capture(ctx context.Context, dir string) (Checkpoint, error)
type Store ¶
type Store struct {
Backend backend.Backend
Prefix string
ClusterID string
VolumeID string
Retention int
TempDir string
MaxImageBytes int64
MaxManifestBytes int64
MaxObjects int
MaxBackups int
Hooks *Hooks
}
Store owns no live metadata. Backend must be independent of the placement index being backed up, for example a separate Local directory or S3 prefix.
func (Store) CreateNamespace ¶
func (Store) InspectCurrent ¶
func (s Store) InspectCurrent(ctx context.Context, namespace, placement, authority string) (Checkpoint, error)
InspectCurrent validates offline current files without changing any source. Unlike a backup manifest it reflects every namespace at its current state.
func (Store) Load ¶
Load discovers a checkpoint from its immutable manifest alone. The caller may retain Key separately; no online cluster index is required.
func (Store) Restore ¶
func (s Store) Restore(ctx context.Context, key, destination string, options RestoreOptions) (Restored, error)
Restore creates a new offline root with namespace.db, placement.db and an authority/ directory. Source objects remain unchanged. Activation always requires runtime reconciliation and durable acknowledgements from Data.
func (Store) RestoreNamespace ¶
func (s Store) RestoreNamespace(ctx context.Context, key, destination string, options NamespaceRestoreOptions) (Restored, error)
RestoreNamespace preserves all current scopes except the explicitly selected one. It publishes a new directory only after the merged DBs, all object roots and the appended restore WAL agree. Activation/fencing remains external.