Documentation
¶
Overview ¶
Package snapshot manages metadata about snapshots stored in repository.
Index ¶
- Constants
- Variables
- func GroupBySource(manifests []*Manifest) [][]*Manifest
- func ListSnapshotManifests(ctx context.Context, rep repo.Repository, src *SourceInfo, ...) ([]manifest.ID, error)
- func SaveSnapshot(ctx context.Context, rep repo.RepositoryWriter, man *Manifest) (manifest.ID, error)
- func UpdateSnapshot(ctx context.Context, rep repo.RepositoryWriter, m *Manifest) error
- type DirEntry
- type DirManifest
- type EntryType
- type HasDirEntry
- type HasDirEntryOrNil
- type Manifest
- func FindPreviousManifests(ctx context.Context, rep repo.Repository, sourceInfo SourceInfo, ...) ([]*Manifest, error)
- func FindSnapshotsByRootObjectID(ctx context.Context, rep repo.Repository, rootID object.ID) ([]*Manifest, error)
- func ListSnapshots(ctx context.Context, rep repo.Repository, si SourceInfo) ([]*Manifest, error)
- func LoadSnapshot(ctx context.Context, rep repo.Repository, manifestID manifest.ID) (*Manifest, error)
- func LoadSnapshots(ctx context.Context, rep repo.Repository, manifestIDs []manifest.ID) ([]*Manifest, error)
- func SortByTime(manifests []*Manifest, reverse bool) []*Manifest
- type Permissions
- type SourceInfo
- type Stats
- type StorageStats
- type StorageUsageDetails
Constants ¶
const ( UsernameLabel = "username" HostnameLabel = "hostname" PathLabel = "path" )
Manifest labels identifying snapshots.
const ManifestType = "snapshot"
ManifestType is the value of the "type" label for snapshot manifests.
Variables ¶
var ErrSnapshotNotFound = errors.New("snapshot not found")
ErrSnapshotNotFound is returned when a snapshot is not found.
Functions ¶
func GroupBySource ¶
GroupBySource returns a slice of slices, such that each result item contains manifests from a single source.
func ListSnapshotManifests ¶
func ListSnapshotManifests(ctx context.Context, rep repo.Repository, src *SourceInfo, tags map[string]string) ([]manifest.ID, error)
ListSnapshotManifests returns the list of snapshot manifests for a given source or all sources if nil.
func SaveSnapshot ¶
func SaveSnapshot(ctx context.Context, rep repo.RepositoryWriter, man *Manifest) (manifest.ID, error)
SaveSnapshot persists given snapshot manifest and returns manifest ID.
func UpdateSnapshot ¶ added in v0.9.6
UpdateSnapshot updates the snapshot by saving the provided data and deleting old manifest ID.
Types ¶
type DirEntry ¶
type DirEntry struct {
Name string `json:"name,omitempty"`
Type EntryType `json:"type,omitempty"`
Permissions Permissions `json:"mode,omitempty"`
FileSize int64 `json:"size,omitempty"`
ModTime fs.UTCTimestamp `json:"mtime,omitempty"`
UserID uint32 `json:"uid,omitempty"`
GroupID uint32 `json:"gid,omitempty"`
ObjectID object.ID `json:"obj"`
DirSummary *fs.DirectorySummary `json:"summ,omitempty"`
}
DirEntry represents a directory entry as stored in JSON stream.
type DirManifest ¶
type DirManifest struct {
StreamType string `json:"stream"` // legacy
Entries []*DirEntry `json:"entries"`
Summary *fs.DirectorySummary `json:"summary"`
}
DirManifest represents serialized contents of a directory. The entries are sorted lexicographically and summary only refers to properties of entries, so directory with the same contents always serializes to exactly the same JSON.
type HasDirEntry ¶ added in v0.4.0
type HasDirEntry interface {
DirEntry() *DirEntry
}
HasDirEntry is implemented by objects that have a DirEntry associated with them.
type HasDirEntryOrNil ¶ added in v0.9.0
HasDirEntryOrNil is implemented by objects that may have a DirEntry stored in the object's corresponding shallow placeholder file.
type Manifest ¶
type Manifest struct {
ID manifest.ID `json:"id"`
Source SourceInfo `json:"source"`
Description string `json:"description"`
StartTime fs.UTCTimestamp `json:"startTime"`
EndTime fs.UTCTimestamp `json:"endTime"`
Stats Stats `json:"stats"`
IncompleteReason string `json:"incomplete,omitempty"`
RootEntry *DirEntry `json:"rootEntry"`
RetentionReasons []string `json:"-"`
Tags map[string]string `json:"tags,omitempty"`
// usage, not persisted, values depend on walking snapshot list in a particular order
StorageStats *StorageStats `json:"storageStats,omitempty"`
// list of manually-defined pins which prevent the snapshot from being deleted.
Pins []string `json:"pins,omitempty"`
}
Manifest represents information about a single point-in-time filesystem snapshot.
func FindPreviousManifests ¶ added in v0.20.0
func FindPreviousManifests(ctx context.Context, rep repo.Repository, sourceInfo SourceInfo, noLaterThan *fs.UTCTimestamp) ([]*Manifest, error)
FindPreviousManifests returns the list of previous snapshots for a given source, including last complete snapshot and possibly some number of incomplete snapshots following it.
func FindSnapshotsByRootObjectID ¶ added in v0.7.2
func FindSnapshotsByRootObjectID(ctx context.Context, rep repo.Repository, rootID object.ID) ([]*Manifest, error)
FindSnapshotsByRootObjectID returns the list of matching snapshots for a given rootID.
func ListSnapshots ¶
func ListSnapshots(ctx context.Context, rep repo.Repository, si SourceInfo) ([]*Manifest, error)
ListSnapshots lists all snapshots for a given source.
func LoadSnapshot ¶ added in v0.4.0
func LoadSnapshot(ctx context.Context, rep repo.Repository, manifestID manifest.ID) (*Manifest, error)
LoadSnapshot loads and parses a snapshot with a given ID.
func LoadSnapshots ¶
func LoadSnapshots(ctx context.Context, rep repo.Repository, manifestIDs []manifest.ID) ([]*Manifest, error)
LoadSnapshots efficiently loads and parses a given list of snapshot IDs.
func SortByTime ¶
SortByTime returns a slice of manifests sorted by start time, and end time as the tie breaker when start time is the same.
func (*Manifest) RootObjectID ¶
RootObjectID returns the ID of a root object.
func (*Manifest) UpdatePins ¶ added in v0.9.6
UpdatePins updates pins in the provided manifest.
type Permissions ¶
type Permissions int
Permissions encapsulates UNIX permissions for a filesystem entry.
func (Permissions) MarshalJSON ¶
func (p Permissions) MarshalJSON() ([]byte, error)
MarshalJSON emits permissions as octal string.
func (*Permissions) UnmarshalJSON ¶
func (p *Permissions) UnmarshalJSON(b []byte) error
UnmarshalJSON parses octal permissions string from JSON.
type SourceInfo ¶
type SourceInfo struct {
Host string `json:"host"`
UserName string `json:"userName"`
Path string `json:"path"`
}
SourceInfo represents the information about snapshot source.
func ListSources ¶
func ListSources(ctx context.Context, rep repo.Repository) ([]SourceInfo, error)
ListSources lists all snapshot sources in a given repository.
func ParseSourceInfo ¶
func ParseSourceInfo(path, hostname, username string) (SourceInfo, error)
ParseSourceInfo parses a given path in the context of given hostname and username and returns SourceInfo. The path may be bare (in which case it's interpreted as local path and canonicalized) or may be 'username@host:path' where path, username and host are not processed.
func (SourceInfo) String ¶
func (ssi SourceInfo) String() string
type Stats ¶
type Stats struct {
// keep all int64 aligned because they will be atomically updated
// +checkatomic
TotalFileSize int64 `json:"totalSize"`
// +checkatomic
ExcludedTotalFileSize int64 `json:"excludedTotalSize"`
// keep all int32 aligned because they will be atomically updated
// +checkatomic
TotalFileCount int32 `json:"fileCount"`
// +checkatomic
CachedFiles int32 `json:"cachedFiles"`
// +checkatomic
NonCachedFiles int32 `json:"nonCachedFiles"`
// +checkatomic
TotalDirectoryCount int32 `json:"dirCount"`
// +checkatomic
ExcludedFileCount int32 `json:"excludedFileCount"`
// +checkatomic
ExcludedDirCount int32 `json:"excludedDirCount"`
// +checkatomic
IgnoredErrorCount int32 `json:"ignoredErrorCount"`
// +checkatomic
ErrorCount int32 `json:"errorCount"`
}
Stats keeps track of snapshot generation statistics.
func (*Stats) AddExcluded ¶
AddExcluded adds the information about excluded file to the statistics.
type StorageStats ¶ added in v0.10.6
type StorageStats struct {
// amount of new unique data in this snapshot that wasn't there before.
// note that this depends on ordering of snapshots.
NewData StorageUsageDetails `json:"newData"`
RunningTotal StorageUsageDetails `json:"runningTotal"`
}
StorageStats encapsulates snapshot storage usage information and running totals.
type StorageUsageDetails ¶ added in v0.10.6
type StorageUsageDetails struct {
// number of bytes in all objects (ignoring content-level deduplication).
// +checkatomic
ObjectBytes int64 `json:"objectBytes"`
// number of bytes in all unique contents (original).
// +checkatomic
OriginalContentBytes int64 `json:"originalContentBytes"`
// number of bytes in all unique contents as stored in the repository.
// +checkatomic
PackedContentBytes int64 `json:"packedContentBytes"`
// number of unique file objects.
// +checkatomic
FileObjectCount int32 `json:"fileObjects"`
// number of unique objects.
// +checkatomic
DirObjectCount int32 `json:"dirObjects"`
// number of unique contents.
// +checkatomic
ContentCount int32 `json:"contents"`
}
StorageUsageDetails provides details about snapshot storage usage.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package policy implements management of snapshot policies.
|
Package policy implements management of snapshot policies. |
|
Package restore manages restoring filesystem snapshots.
|
Package restore manages restoring filesystem snapshots. |
|
Package snapshotfs implements virtual filesystem on top of snapshots in repo.Repository.
|
Package snapshotfs implements virtual filesystem on top of snapshots in repo.Repository. |
|
Package snapshotgc implements garbage collection of contents that are no longer referenced through snapshots.
|
Package snapshotgc implements garbage collection of contents that are no longer referenced through snapshots. |
|
Package snapshotmaintenance provides helpers to run snapshot GC and low-level repository snapshotmaintenance.
|
Package snapshotmaintenance provides helpers to run snapshot GC and low-level repository snapshotmaintenance. |
|
Package upload manages snapshot uploads.
|
Package upload manages snapshot uploads. |