Documentation ¶
Overview ¶
Package repo implements content-addressable Repository on top of BLOB storage.
Index ¶
- Constants
- Variables
- func Connect(ctx context.Context, configFile string, st blob.Storage, password string, ...) error
- func ConnectAPIServer(ctx context.Context, configFile string, si *APIServerInfo, password string, ...) error
- func DecodeToken(token string) (blob.ConnectionInfo, string, error)
- func Disconnect(ctx context.Context, configFile string) error
- func GetPersistedPassword(ctx context.Context, configFile string) (string, bool)
- func Initialize(ctx context.Context, st blob.Storage, opt *NewRepositoryOptions, ...) error
- func RecoverFormatBlob(ctx context.Context, st blob.Storage, blobID blob.ID, optionalLength int64) ([]byte, error)
- type APIServerInfo
- type ConnectOptions
- type DirectRepository
- func (r *DirectRepository) BlobStorage() blob.Storage
- func (r *DirectRepository) Close(ctx context.Context) error
- func (r *DirectRepository) ConfigFilename() string
- func (r *DirectRepository) ContentManager() *content.Manager
- func (r *DirectRepository) DeleteManifest(ctx context.Context, id manifest.ID) error
- func (r *DirectRepository) DeriveKey(purpose []byte, keyLength int) []byte
- func (r *DirectRepository) FindManifests(ctx context.Context, labels map[string]string) ([]*manifest.EntryMetadata, error)
- func (r *DirectRepository) Flush(ctx context.Context) error
- func (r *DirectRepository) GetManifest(ctx context.Context, id manifest.ID, data interface{}) (*manifest.EntryMetadata, error)
- func (r *DirectRepository) Hostname() string
- func (r *DirectRepository) NewObjectWriter(ctx context.Context, opt object.WriterOptions) object.Writer
- func (r *DirectRepository) OpenObject(ctx context.Context, id object.ID) (object.Reader, error)
- func (r *DirectRepository) PutManifest(ctx context.Context, labels map[string]string, payload interface{}) (manifest.ID, error)
- func (r *DirectRepository) Refresh(ctx context.Context) error
- func (r *DirectRepository) RefreshPeriodically(ctx context.Context, interval time.Duration)
- func (r *DirectRepository) SetCachingConfig(ctx context.Context, opt *content.CachingOptions) error
- func (r *DirectRepository) Time() time.Time
- func (r *DirectRepository) Token(password string) (string, error)
- func (r *DirectRepository) Upgrade(ctx context.Context) error
- func (r *DirectRepository) Username() string
- func (r *DirectRepository) VerifyObject(ctx context.Context, id object.ID) ([]content.ID, error)
- type LocalConfig
- type NewRepositoryOptions
- type Options
- type Repository
Constants ¶
const CacheDirMarkerFile = ".kopia-cache"
CacheDirMarkerFile is the name of the marker file indicating a directory contains Kopia caches.
const FormatBlobID = "kopia.repository"
FormatBlobID is the identifier of a BLOB that describes repository format.
Variables ¶
var ( BuildInfo = "unknown" BuildVersion = "v0-unofficial" )
BuildInfo is the build information of Kopia.
var ErrAlreadyInitialized = errors.Errorf("repository already initialized")
ErrAlreadyInitialized indicates that repository has already been initialized.
var ErrInvalidPassword = errors.Errorf("invalid repository password")
ErrInvalidPassword is returned when repository password is invalid.
var ErrRepositoryNotInitialized = errors.Errorf("repository not initialized in the provided storage")
ErrRepositoryNotInitialized is returned when attempting to connect to repository that has not been initialized.
var KeyRingEnabled = false
KeyRingEnabled enables password persistence uses OS-specific keyring.
Functions ¶
func Connect ¶
func Connect(ctx context.Context, configFile string, st blob.Storage, password string, opt *ConnectOptions) error
Connect connects to the repository in the specified storage and persists the configuration and credentials in the file provided.
func ConnectAPIServer ¶ added in v0.6.0
func ConnectAPIServer(ctx context.Context, configFile string, si *APIServerInfo, password string, opt *ConnectOptions) error
ConnectAPIServer sets up repository connection to a particular API server.
func DecodeToken ¶
func DecodeToken(token string) (blob.ConnectionInfo, string, error)
DecodeToken decodes the provided token and returns connection info and password if persisted.
func Disconnect ¶
Disconnect removes the specified configuration file and any local cache directories.
func GetPersistedPassword ¶ added in v0.5.2
GetPersistedPassword retrieves persisted password for a given repository config.
func Initialize ¶
func Initialize(ctx context.Context, st blob.Storage, opt *NewRepositoryOptions, password string) error
Initialize creates initial repository data structures in the specified storage with given credentials.
func RecoverFormatBlob ¶
func RecoverFormatBlob(ctx context.Context, st blob.Storage, blobID blob.ID, optionalLength int64) ([]byte, error)
RecoverFormatBlob attempts to recover format blob replica from the specified file. The format blob can be either the prefix or a suffix of the given file. optionally the length can be provided (if known) to speed up recovery.
Types ¶
type APIServerInfo ¶ added in v0.6.0
type APIServerInfo struct { BaseURL string `json:"url"` TrustedServerCertificateFingerprint string `json:"serverCertFingerprint"` }
APIServerInfo is remote repository configuration stored in local configuration.
type ConnectOptions ¶
type ConnectOptions struct { PersistCredentials bool `json:"persistCredentials"` HostnameOverride string `json:"hostnameOverride"` UsernameOverride string `json:"usernameOverride"` content.CachingOptions }
ConnectOptions specifies options when persisting configuration to connect to a repository.
type DirectRepository ¶ added in v0.6.0
type DirectRepository struct { Blobs blob.Storage Content *content.Manager Objects *object.Manager Manifests *manifest.Manager UniqueID []byte ConfigFile string // contains filtered or unexported fields }
DirectRepository is an implementation of repository that directly manipulates underlying storage.
func OpenWithConfig ¶
func OpenWithConfig(ctx context.Context, st blob.Storage, lc *LocalConfig, password string, options *Options, caching *content.CachingOptions) (*DirectRepository, error)
OpenWithConfig opens the repository with a given configuration, avoiding the need for a config file.
func (*DirectRepository) BlobStorage ¶ added in v0.6.0
func (r *DirectRepository) BlobStorage() blob.Storage
BlobStorage returns the blob storage.
func (*DirectRepository) Close ¶ added in v0.6.0
func (r *DirectRepository) Close(ctx context.Context) error
Close closes the repository and releases all resources.
func (*DirectRepository) ConfigFilename ¶ added in v0.6.0
func (r *DirectRepository) ConfigFilename() string
ConfigFilename returns the name of the configuration file
func (*DirectRepository) ContentManager ¶ added in v0.6.0
func (r *DirectRepository) ContentManager() *content.Manager
ContentManager returns the content manager.
func (*DirectRepository) DeleteManifest ¶ added in v0.6.0
DeleteManifest deletes the manifest with a given ID.
func (*DirectRepository) DeriveKey ¶ added in v0.6.0
func (r *DirectRepository) DeriveKey(purpose []byte, keyLength int) []byte
DeriveKey derives encryption key of the provided length from the master key.
func (*DirectRepository) FindManifests ¶ added in v0.6.0
func (r *DirectRepository) FindManifests(ctx context.Context, labels map[string]string) ([]*manifest.EntryMetadata, error)
FindManifests returns metadata for manifests matching given set of labels.
func (*DirectRepository) Flush ¶ added in v0.6.0
func (r *DirectRepository) Flush(ctx context.Context) error
Flush waits for all in-flight writes to complete.
func (*DirectRepository) GetManifest ¶ added in v0.6.0
func (r *DirectRepository) GetManifest(ctx context.Context, id manifest.ID, data interface{}) (*manifest.EntryMetadata, error)
GetManifest returns the given manifest data and metadata.
func (*DirectRepository) Hostname ¶ added in v0.6.0
func (r *DirectRepository) Hostname() string
Hostname returns the hostname that connected to the repository.
func (*DirectRepository) NewObjectWriter ¶ added in v0.6.0
func (r *DirectRepository) NewObjectWriter(ctx context.Context, opt object.WriterOptions) object.Writer
NewObjectWriter creates an object writer.
func (*DirectRepository) OpenObject ¶ added in v0.6.0
OpenObject opens the reader for a given object, returns object.ErrNotFound
func (*DirectRepository) PutManifest ¶ added in v0.6.0
func (r *DirectRepository) PutManifest(ctx context.Context, labels map[string]string, payload interface{}) (manifest.ID, error)
PutManifest saves the given manifest payload with a set of labels.
func (*DirectRepository) Refresh ¶ added in v0.6.0
func (r *DirectRepository) Refresh(ctx context.Context) error
Refresh periodically makes external changes visible to repository.
func (*DirectRepository) RefreshPeriodically ¶ added in v0.6.0
func (r *DirectRepository) RefreshPeriodically(ctx context.Context, interval time.Duration)
RefreshPeriodically periodically refreshes the repository to reflect the changes made by other hosts.
func (*DirectRepository) SetCachingConfig ¶ added in v0.6.0
func (r *DirectRepository) SetCachingConfig(ctx context.Context, opt *content.CachingOptions) error
SetCachingConfig changes caching configuration for a given repository.
func (*DirectRepository) Time ¶ added in v0.6.0
func (r *DirectRepository) Time() time.Time
Time returns the current local time for the repo
func (*DirectRepository) Token ¶ added in v0.6.0
func (r *DirectRepository) Token(password string) (string, error)
Token returns an opaque token that contains repository connection information and optionally the provided password.
func (*DirectRepository) Upgrade ¶ added in v0.6.0
func (r *DirectRepository) Upgrade(ctx context.Context) error
Upgrade upgrades repository data structures to the latest version.
func (*DirectRepository) Username ¶ added in v0.6.0
func (r *DirectRepository) Username() string
Username returns the username that's connect to the repository.
func (*DirectRepository) VerifyObject ¶ added in v0.6.0
VerifyObject verifies that the given object is stored properly in a repository and returns backing content IDs.
type LocalConfig ¶
type LocalConfig struct { // APIServer is only provided for remote repository. APIServer *APIServerInfo `json:"apiServer,omitempty"` // Storage is only provided for direct repository access. Storage *blob.ConnectionInfo `json:"storage,omitempty"` Caching *content.CachingOptions `json:"caching,omitempty"` Hostname string `json:"hostname"` Username string `json:"username"` }
LocalConfig is a configuration of Kopia stored in a configuration file.
type NewRepositoryOptions ¶
type NewRepositoryOptions struct { UniqueID []byte `json:"uniqueID"` // force the use of particular unique ID BlockFormat content.FormattingOptions `json:"blockFormat"` DisableHMAC bool `json:"disableHMAC"` ObjectFormat object.Format `json:"objectFormat"` // object format }
NewRepositoryOptions specifies options that apply to newly created repositories. All fields are optional, when not provided, reasonable defaults will be used.
type Options ¶
type Options struct { TraceStorage func(f string, args ...interface{}) // Logs all storage access using provided Printf-style function ObjectManagerOptions object.ManagerOptions TimeNowFunc func() time.Time // Time provider }
Options provides configuration parameters for connection to a repository.
type Repository ¶
type Repository interface { OpenObject(ctx context.Context, id object.ID) (object.Reader, error) NewObjectWriter(ctx context.Context, opt object.WriterOptions) object.Writer VerifyObject(ctx context.Context, id object.ID) ([]content.ID, error) GetManifest(ctx context.Context, id manifest.ID, data interface{}) (*manifest.EntryMetadata, error) PutManifest(ctx context.Context, labels map[string]string, payload interface{}) (manifest.ID, error) FindManifests(ctx context.Context, labels map[string]string) ([]*manifest.EntryMetadata, error) DeleteManifest(ctx context.Context, id manifest.ID) error Hostname() string Username() string Time() time.Time Refresh(ctx context.Context) error Flush(ctx context.Context) error Close(ctx context.Context) error }
Repository exposes public API of Kopia repository, including objects and manifests.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package blob implements simple storage of immutable, unstructured binary large objects (BLOBs).
|
Package blob implements simple storage of immutable, unstructured binary large objects (BLOBs). |
azure
Package azure implements Azure Blob Storage.
|
Package azure implements Azure Blob Storage. |
b2
Package b2 implements Storage based on an Backblaze B2 bucket.
|
Package b2 implements Storage based on an Backblaze B2 bucket. |
filesystem
Package filesystem implements filesystem-based Storage.
|
Package filesystem implements filesystem-based Storage. |
gcs
Package gcs implements Storage based on Google Cloud Storage bucket.
|
Package gcs implements Storage based on Google Cloud Storage bucket. |
logging
Package logging implements wrapper around Storage that logs all activity.
|
Package logging implements wrapper around Storage that logs all activity. |
providers
Package providers registers all storage providers that are included as part of Kopia.
|
Package providers registers all storage providers that are included as part of Kopia. |
s3
Package s3 implements Storage based on an S3 bucket.
|
Package s3 implements Storage based on an S3 bucket. |
sftp
Package sftp implements blob storage provided for SFTP/SSH.
|
Package sftp implements blob storage provided for SFTP/SSH. |
sharded
Package sharded implements common support for sharded blob providers, such as filesystem or webdav.
|
Package sharded implements common support for sharded blob providers, such as filesystem or webdav. |
webdav
Package webdav implements WebDAV-based Storage.
|
Package webdav implements WebDAV-based Storage. |
Package compression manages compression algorithm implementations.
|
Package compression manages compression algorithm implementations. |
Package content implements repository support for content-addressable storage.
|
Package content implements repository support for content-addressable storage. |
Package encryption manages content encryption algorithms.
|
Package encryption manages content encryption algorithms. |
Package hashing encapsulates all keyed hashing algorithms.
|
Package hashing encapsulates all keyed hashing algorithms. |
Package logging provides loggers for Kopia.
|
Package logging provides loggers for Kopia. |
Package maintenance manages automatic repository maintenance.
|
Package maintenance manages automatic repository maintenance. |
Package manifest implements support for managing JSON-based manifests in repository.
|
Package manifest implements support for managing JSON-based manifests in repository. |
Package object implements repository support for content-addressable objects of arbitrary size.
|
Package object implements repository support for content-addressable objects of arbitrary size. |
Package splitter manages splitting of object data into chunks.
|
Package splitter manages splitting of object data into chunks. |