Documentation ¶
Index ¶
- Constants
- Variables
- func AssertBackupBasesEqual(t *testing.T, expect, got BackupBases)
- func NewConn(s storage.Storage) *conn
- type BackupBase
- type BackupBaseBuilder
- func (builder *BackupBaseBuilder) AppendReasons(reasons ...identity.Reasoner) *BackupBaseBuilder
- func (builder *BackupBaseBuilder) Build() BackupBase
- func (builder *BackupBaseBuilder) MarkAssistBase() *BackupBaseBuilder
- func (builder *BackupBaseBuilder) WithReasons(reasons ...identity.Reasoner) *BackupBaseBuilder
- type BackupBases
- type BackupStats
- type ByteCounter
- type DetailsMergeInfoer
- type MockBackupBases
- func (bb MockBackupBases) ConvertToAssistBase(backupID model.StableID)
- func (bb MockBackupBases) DisableAssistBases()
- func (bb MockBackupBases) DisableMergeBases()
- func (bb MockBackupBases) MergeBackupBases(ctx context.Context, other BackupBases, ...) BackupBases
- func (bb MockBackupBases) MergeBases() []BackupBase
- func (bb MockBackupBases) MinAssistVersion() int
- func (bb MockBackupBases) MinBackupVersion() int
- func (bb *MockBackupBases) MockDisableAssistBases() *MockBackupBases
- func (bb *MockBackupBases) MockDisableMergeBases() *MockBackupBases
- func (bb MockBackupBases) SnapshotAssistBases() []BackupBase
- func (bb MockBackupBases) UniqueAssistBases() []BackupBase
- func (bb *MockBackupBases) WithAssistBases(b ...BackupBase) *MockBackupBases
- func (bb *MockBackupBases) WithMergeBases(b ...BackupBase) *MockBackupBases
- type ModelStore
- func (ms *ModelStore) Close(ctx context.Context) error
- func (ms *ModelStore) Delete(ctx context.Context, s model.Schema, id model.StableID) error
- func (ms *ModelStore) DeleteWithModelStoreIDs(ctx context.Context, ids ...manifest.ID) error
- func (ms *ModelStore) Get(ctx context.Context, s model.Schema, id model.StableID, m model.Model) error
- func (ms *ModelStore) GetIDsForType(ctx context.Context, s model.Schema, tags map[string]string) ([]*model.BaseModel, error)
- func (ms *ModelStore) GetWithModelStoreID(ctx context.Context, s model.Schema, id manifest.ID, m model.Model) error
- func (ms *ModelStore) Put(ctx context.Context, s model.Schema, m model.Model) error
- func (ms *ModelStore) Update(ctx context.Context, s model.Schema, m model.Model) error
- type Wrapper
- func (w *Wrapper) Close(ctx context.Context) error
- func (w Wrapper) ConsumeBackupCollections(ctx context.Context, backupReasons []identity.Reasoner, bases BackupBases, ...) (*BackupStats, *details.Builder, DetailsMergeInfoer, error)
- func (w Wrapper) NewBaseFinder(bg store.BackupGetter) (*baseFinder, error)
- func (w Wrapper) ProduceRestoreCollections(ctx context.Context, snapshotID string, paths []path.RestorePaths, ...) ([]data.RestoreCollection, error)
- func (w Wrapper) RepoMaintenance(ctx context.Context, storer store.Storer, opts repository.Maintenance, ...) error
- func (w *Wrapper) SetRetentionParameters(ctx context.Context, retention repository.Retention) error
- func (w *Wrapper) UpdatePersistentConfig(ctx context.Context, config repository.PersistentConfig) error
Constants ¶
const ( TagBackupID = "backup-id" TagBackupCategory = "is-canon-backup" )
common manifest tags
Variables ¶
var ( ErrSettingDefaultConfig = clues.New("setting default repo config values") ErrorRepoAlreadyExists = clues.New("repo already exists") )
var (
ErrNoRestorePath = clues.New("no restore path given")
)
Functions ¶
func AssertBackupBasesEqual ¶
func AssertBackupBasesEqual(t *testing.T, expect, got BackupBases)
Types ¶
type BackupBase ¶
type BackupBase struct { Backup *backup.Backup ItemDataSnapshot *snapshot.Manifest // Reasons contains the tenant, protected resource and service/categories that // caused this snapshot to be selected as a base. It's possible some // (tenant, protected resources) will have a subset of the categories as // the reason for selecting a snapshot. For example: // 1. backup user1 email,contacts -> B1 // 2. backup user1 contacts -> B2 (uses B1 as base) // 3. backup user1 email,contacts,events (uses B1 for email, B2 for contacts) Reasons []identity.Reasoner }
func (BackupBase) GetReasons ¶
func (bb BackupBase) GetReasons() []identity.Reasoner
func (BackupBase) GetSnapshotID ¶
func (bb BackupBase) GetSnapshotID() manifest.ID
func (BackupBase) GetSnapshotTag ¶
func (bb BackupBase) GetSnapshotTag(key string) (string, bool)
type BackupBaseBuilder ¶
type BackupBaseBuilder struct {
// contains filtered or unexported fields
}
func NewBackupBaseBuilder ¶
func NewBackupBaseBuilder(idPrefix string, id int) *BackupBaseBuilder
func (*BackupBaseBuilder) AppendReasons ¶
func (builder *BackupBaseBuilder) AppendReasons( reasons ...identity.Reasoner, ) *BackupBaseBuilder
func (*BackupBaseBuilder) Build ¶
func (builder *BackupBaseBuilder) Build() BackupBase
func (*BackupBaseBuilder) MarkAssistBase ¶
func (builder *BackupBaseBuilder) MarkAssistBase() *BackupBaseBuilder
func (*BackupBaseBuilder) WithReasons ¶
func (builder *BackupBaseBuilder) WithReasons( reasons ...identity.Reasoner, ) *BackupBaseBuilder
type BackupBases ¶
type BackupBases interface { // ConvertToAssistBase converts the base with the given backup ID from a merge // base to an assist base. ConvertToAssistBase(backupID model.StableID) // MergeBases returns a []BackupBase that corresponds to all the bases that // will source unchanged information for this backup during hierarchy merging, // snapshot creation, and details merging. MergeBases() []BackupBase // DisableMergeBases converts all merge bases in this BackupBases to assist // bases. These bases can still participate in sourcing data kopia considers // "cached" during the snapshot process and can source backup details entries // for those cached items. However, they won't be used to source unchanged // items during hierarchy merging, snapshot creation, or details merging. // // This call is order sensitive with DisableAssistBases. DisableMergeBases() // UniqueAssistBases returns the set of assist bases for the backup operation. // Assist bases are used to source item data and details entries if the item // is considered "cached" by kopia. They are not used to source unchanged // items during hierarchy merging. UniqueAssistBases() []BackupBase // DisableAssistBases clears the set of assist bases for this backup. Doing so // will result in kopia not finding any "cached" items and assist bases won't // participate in details merging. // // This call is order sensitive with DisableMergeBases. DisableAssistBases() // MinBackupVersion returns the lowest version of all merge backups in the // BackupBases. MinBackupVersion() int // MinAssisttVersion returns the lowest version of all assist backups in the // BackupBases. MinAssistVersion() int // MergeBackupBases takes another BackupBases and merges it's contained assist // and merge bases into this BackupBases. The passed in BackupBases is // considered an older alternative to this BackupBases meaning bases from // other won't be selected unless there's no item in this BackupBases to cover // that Reason. // // Callers pass in reasonToKey to control how individual BackupBase items are // selected. For example, to migrate from using user name to user ID as the // protected resource in the Reason the reasonToKey function could map // BackupBase items with the same tenant, service, and category to the same // key. This works because backup operations are already per protected // resource. // // This call is order sensitive with DisableMergeBases and DisableAssistBases. MergeBackupBases( ctx context.Context, other BackupBases, reasonToKey func(identity.Reasoner) string, ) BackupBases // SnapshotAssistBases returns the set of bases to use for kopia assisted // incremental snapshot operations. It consists of the union of merge bases // and assist bases. If DisableAssistBases has been called then it returns // nil. SnapshotAssistBases() []BackupBase }
TODO(ashmrtn): Move this into some inject package. Here to avoid import cycles.
func EmptyBackupBase ¶
func EmptyBackupBase() BackupBases
type BackupStats ¶
type BackupStats struct { SnapshotID string TotalHashedBytes int64 TotalUploadedBytes int64 TotalNonMetaUploadedBytes int64 TotalFileCount int TotalNonMetaFileCount int CachedFileCount int UncachedFileCount int TotalDirectoryCount int ErrorCount int IgnoredErrorCount int ExpectedIgnoredErrorCount int Incomplete bool IncompleteReason string }
type ByteCounter ¶
type ByteCounter interface {
Count(numBytes int64)
}
type DetailsMergeInfoer ¶
type DetailsMergeInfoer interface { // ItemsToMerge returns the number of items that need to be merged. ItemsToMerge() int // GetNewPathRefs takes the old RepoRef and old LocationRef of an item and // returns the new RepoRef and the new location of the item the item. If the // item shouldn't be merged nils are returned. GetNewPathRefs( oldRef *path.Builder, modTime time.Time, oldLoc details.LocationIDer, ) (path.Path, *path.Builder, error) }
type MockBackupBases ¶
type MockBackupBases struct {
// contains filtered or unexported fields
}
func NewMockBackupBases ¶
func NewMockBackupBases() *MockBackupBases
func (MockBackupBases) ConvertToAssistBase ¶
func (MockBackupBases) DisableAssistBases ¶
func (bb MockBackupBases) DisableAssistBases()
func (MockBackupBases) DisableMergeBases ¶
func (bb MockBackupBases) DisableMergeBases()
func (MockBackupBases) MergeBackupBases ¶
func (bb MockBackupBases) MergeBackupBases( ctx context.Context, other BackupBases, reasonToKey func(reason identity.Reasoner) string, ) BackupBases
MergeBackupBases reduces the two BackupBases into a single BackupBase. Assumes the passed in BackupBases represents a prior backup version (across some migration that disrupts lookup), and that the BackupBases used to call this function contains the current version.
This call should be made prior to Disable*Bases being called on either the called BackupBases or the passed in BackupBases.
reasonToKey should be a function that, given a Reasoner, will produce some string that represents Reasoner in the context of the merge operation. For example, to merge BackupBases across a ProtectedResource migration, the Reasoner's service and category can be used as the key.
Selection priority, for each reason key generated by reasonsToKey, follows these rules:
- If the called BackupBases has an entry for a given reason, ignore the other BackupBases matching that reason.
- If the called BackupBases has only AssistBases, look for a matching MergeBase manifest in the other BackupBases.
- If the called BackupBases has no entry for a reason, look for a matching MergeBase in the other BackupBases.
func (MockBackupBases) MergeBases ¶
func (bb MockBackupBases) MergeBases() []BackupBase
func (MockBackupBases) MinAssistVersion ¶
func (bb MockBackupBases) MinAssistVersion() int
func (MockBackupBases) MinBackupVersion ¶
func (bb MockBackupBases) MinBackupVersion() int
func (*MockBackupBases) MockDisableAssistBases ¶
func (bb *MockBackupBases) MockDisableAssistBases() *MockBackupBases
func (*MockBackupBases) MockDisableMergeBases ¶
func (bb *MockBackupBases) MockDisableMergeBases() *MockBackupBases
func (MockBackupBases) SnapshotAssistBases ¶
func (bb MockBackupBases) SnapshotAssistBases() []BackupBase
func (MockBackupBases) UniqueAssistBases ¶
func (bb MockBackupBases) UniqueAssistBases() []BackupBase
func (*MockBackupBases) WithAssistBases ¶
func (bb *MockBackupBases) WithAssistBases(b ...BackupBase) *MockBackupBases
func (*MockBackupBases) WithMergeBases ¶
func (bb *MockBackupBases) WithMergeBases(b ...BackupBase) *MockBackupBases
type ModelStore ¶
type ModelStore struct {
// contains filtered or unexported fields
}
ModelStore must not be accessed after the given KopiaWrapper is closed.
func NewModelStore ¶
func NewModelStore(c *conn) (*ModelStore, error)
func (*ModelStore) Delete ¶
Delete deletes the model with the given StableID. Turns into a noop if id is not empty but the model does not exist. Returns an error if multiple models have the same StableID.
func (*ModelStore) DeleteWithModelStoreIDs ¶
DeleteWithModelStoreID deletes the model(s) with the given ModelStoreID(s) from the model store. For an individual ID, turns into a noop if the ID is non-empty but the model doesn't exist. All model deletions should be persisted atomically.
Will not make any changes if any deletion attempt returns an error.
func (*ModelStore) Get ¶
func (ms *ModelStore) Get( ctx context.Context, s model.Schema, id model.StableID, m model.Model, ) error
Get deserializes the model with the given StableID into data. Returns an error if the persisted model has a different type than expected or if multiple models have the same StableID.
func (*ModelStore) GetIDsForType ¶
func (ms *ModelStore) GetIDsForType( ctx context.Context, s model.Schema, tags map[string]string, ) ([]*model.BaseModel, error)
GetIDsForType returns metadata for all models that match the given type and have the given tags. Returned IDs can be used in subsequent calls to Get, Update, or Delete.
func (*ModelStore) GetWithModelStoreID ¶
func (ms *ModelStore) GetWithModelStoreID( ctx context.Context, s model.Schema, id manifest.ID, m model.Model, ) error
GetWithModelStoreID deserializes the model with the given ModelStoreID into data. Returns and error if the persisted model has a different type than expected.
func (*ModelStore) Put ¶
Put adds a model of the given type to the persistent model store. Any tags given to this function can later be used to help lookup the model.
func (*ModelStore) Update ¶
Update adds the new version of the model with the given StableID to the model store and deletes the version of the model with old ModelStoreID if the old and new ModelStoreIDs do not match. Returns an error if another model has the same StableID but a different ModelType or ModelStoreID or there is no previous version of the model. If an error occurs no visible changes will be made to the stored model.
type Wrapper ¶
type Wrapper struct {
// contains filtered or unexported fields
}
func NewWrapper ¶
func (Wrapper) ConsumeBackupCollections ¶
func (w Wrapper) ConsumeBackupCollections( ctx context.Context, backupReasons []identity.Reasoner, bases BackupBases, collections []data.BackupCollection, globalExcludeSet prefixmatcher.StringSetReader, additionalTags map[string]string, buildTreeWithBase bool, counter *count.Bus, errs *fault.Bus, ) (*BackupStats, *details.Builder, DetailsMergeInfoer, error)
ConsumeBackupCollections takes a set of collections and creates a kopia snapshot with the data that they contain. previousSnapshots is used for incremental backups and should represent the base snapshot from which metadata is sourced from as well as any incomplete snapshot checkpoints that may contain more recent data than the base snapshot. The absence of previousSnapshots causes a complete backup of all data.
func (Wrapper) NewBaseFinder ¶
func (w Wrapper) NewBaseFinder(bg store.BackupGetter) (*baseFinder, error)
func (Wrapper) ProduceRestoreCollections ¶
func (w Wrapper) ProduceRestoreCollections( ctx context.Context, snapshotID string, paths []path.RestorePaths, bcounter ByteCounter, errs *fault.Bus, ) ([]data.RestoreCollection, error)
ProduceRestoreCollections looks up all paths- assuming each is an item declaration, not a directory- in the snapshot with id snapshotID. The path should be the full path of the item from the root. Returns the results as a slice of single- item DataCollections, where the DataCollection.FullPath() matches the path. If the item does not exist in kopia or is not a file an error is returned. The UUID of the returned DataStreams will be the name of the kopia file the data is sourced from.
func (Wrapper) RepoMaintenance ¶
func (w Wrapper) RepoMaintenance( ctx context.Context, storer store.Storer, opts repository.Maintenance, errs *fault.Bus, ) error
func (*Wrapper) SetRetentionParameters ¶
func (w *Wrapper) SetRetentionParameters( ctx context.Context, retention repository.Retention, ) error
SetRetentionParameters sets configuration values related to immutable backups and retention policies on the storage bucket. The minimum retention period must be >= 24hrs due to kopia default expectations about full maintenance.
func (*Wrapper) UpdatePersistentConfig ¶
func (w *Wrapper) UpdatePersistentConfig( ctx context.Context, config repository.PersistentConfig, ) error