Documentation ¶
Overview ¶
Package checker defines the framework for creating and restoring snapshots with a data integrity check
Index ¶
- Constants
- type Checker
- func (chk *Checker) Cleanup()
- func (chk *Checker) DeleteSnapshot(ctx context.Context, snapID string, opts map[string]string) error
- func (chk *Checker) GetLiveSnapIDs() []string
- func (chk *Checker) GetSnapIDs() []string
- func (chk *Checker) GetSnapshotMetadata(ctx context.Context, snapID string) (*SnapshotMetadata, error)
- func (chk *Checker) IsSnapshotIDDeleted(ctx context.Context, snapID string) (bool, error)
- func (chk *Checker) RestoreSnapshot(ctx context.Context, snapID string, reportOut io.Writer, ...) error
- func (chk *Checker) RestoreSnapshotToPath(ctx context.Context, snapID, destPath string, reportOut io.Writer, ...) error
- func (chk *Checker) RestoreVerifySnapshot(ctx context.Context, snapID, destPath string, ssMeta *SnapshotMetadata, ...) error
- func (chk *Checker) TakeSnapshot(ctx context.Context, sourceDir string, opts map[string]string) (snapID string, err error)
- func (chk *Checker) VerifySnapshotMetadata(ctx context.Context) error
- type SnapshotMetadata
Constants ¶
const ( DeletedSnapshotsIdxName = "deleted-snapshots-idx" LiveSnapshotsIdxName = "live-snapshots-idx" AllSnapshotsIdxName = "all-snapshots-idx" )
Index names for categorizing snapshot lookups.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Checker ¶ added in v0.6.0
type Checker struct { RestoreDir string RecoveryMode bool DeleteLimit int SnapIDIndex snapmeta.Index // contains filtered or unexported fields }
Checker is an object that can take snapshots and restore them, performing a validation for data consistency.
func NewChecker ¶ added in v0.6.0
func NewChecker(snapIssuer robustness.Snapshotter, snapmetaStore robustness.Store, restoreDir string) (*Checker, error)
NewChecker instantiates a new Checker, returning its pointer. A temporary directory is created to mount restored data.
func (*Checker) Cleanup ¶ added in v0.6.0
func (chk *Checker) Cleanup()
Cleanup cleans up the Checker's temporary restore data directory.
func (*Checker) DeleteSnapshot ¶ added in v0.6.0
func (chk *Checker) DeleteSnapshot(ctx context.Context, snapID string, opts map[string]string) error
DeleteSnapshot performs the Snapshotter's DeleteSnapshot action, and marks the snapshot with the given snapshot ID as deleted.
func (*Checker) GetLiveSnapIDs ¶ added in v0.6.0
GetLiveSnapIDs gets the list of snapshot IDs being tracked by the checker's snapshot store that do not have a deletion time associated with them.
func (*Checker) GetSnapIDs ¶ added in v0.6.0
GetSnapIDs gets the list of snapshot IDs being tracked by the checker's snapshot store.
func (*Checker) GetSnapshotMetadata ¶ added in v0.6.0
func (chk *Checker) GetSnapshotMetadata(ctx context.Context, snapID string) (*SnapshotMetadata, error)
GetSnapshotMetadata gets the metadata associated with the given snapshot ID.
func (*Checker) IsSnapshotIDDeleted ¶ added in v0.6.0
IsSnapshotIDDeleted reports whether the metadata associated with the provided snapshot ID has it marked as deleted.
func (*Checker) RestoreSnapshot ¶ added in v0.6.0
func (chk *Checker) RestoreSnapshot(ctx context.Context, snapID string, reportOut io.Writer, opts map[string]string) error
RestoreSnapshot restores a snapshot to the Checker's temporary restore directory using the Checker's Snapshotter, and performs a data consistency check on the resulting tree using the saved snapshot data.
func (*Checker) RestoreSnapshotToPath ¶ added in v0.6.0
func (chk *Checker) RestoreSnapshotToPath(ctx context.Context, snapID, destPath string, reportOut io.Writer, opts map[string]string) error
RestoreSnapshotToPath restores a snapshot to the requested path using the Checker's Snapshotter, and performs a data consistency check on the resulting tree using the saved snapshot data.
func (*Checker) RestoreVerifySnapshot ¶ added in v0.6.0
func (chk *Checker) RestoreVerifySnapshot(ctx context.Context, snapID, destPath string, ssMeta *SnapshotMetadata, reportOut io.Writer, opts map[string]string) error
RestoreVerifySnapshot restores a snapshot and verifies its integrity against the metadata provided.
func (*Checker) TakeSnapshot ¶ added in v0.6.0
func (chk *Checker) TakeSnapshot(ctx context.Context, sourceDir string, opts map[string]string) (snapID string, err error)
TakeSnapshot gathers state information on the requested snapshot path, then performs the snapshot action defined by the Checker's Snapshotter.
func (*Checker) VerifySnapshotMetadata ¶ added in v0.6.0
VerifySnapshotMetadata compares the list of live snapshot IDs present in the Checker's metadata against a list of live snapshot IDs in the connected repository. This should not be called concurrently, as there is no thread safety guaranteed.
type SnapshotMetadata ¶ added in v0.6.0
type SnapshotMetadata struct { SnapID string `json:"snapID"` SnapStartTime time.Time `json:"snapStartTime"` SnapEndTime time.Time `json:"snapEndTime"` DeletionTime time.Time `json:"deletionTime"` ValidationData []byte `json:"validationData"` }
SnapshotMetadata holds metadata associated with a given snapshot.
func (*SnapshotMetadata) IsDeleted ¶ added in v0.8.0
func (ssMeta *SnapshotMetadata) IsDeleted() bool
IsDeleted returns true if the SnapshotMetadata references a snapshot ID that has been deleted.