backend

package
v0.7.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 22, 2017 License: BSD-2-Clause Imports: 15 Imported by: 0

Documentation

Overview

Package backend provides local and remote storage for restic repositories. All backends need to implement the Backend interface. There is a MemBackend, which stores all data in a map internally and can be used for testing.

Index

Constants

This section is empty.

Variables

View Source
var ErrLayoutDetectionFailed = errors.New("auto-detecting the filesystem layout failed")

ErrLayoutDetectionFailed is returned by DetectLayout() when the layout cannot be detected automatically.

View Source
var Modes = struct{ Dir, File os.FileMode }{0700, 0600}

Modes holds the default modes for directories and files for file-based backends.

View Source
var Paths = struct {
	Data      string
	Snapshots string
	Index     string
	Locks     string
	Keys      string
	Temp      string
	Config    string
}{
	"data",
	"snapshots",
	"index",
	"locks",
	"keys",
	"tmp",
	"config",
}

Paths contains the default paths for file-based backends (e.g. local).

Functions

func LoadAll

func LoadAll(ctx context.Context, be restic.Backend, h restic.Handle) (buf []byte, err error)

LoadAll reads all data stored in the backend for the handle.

func Transport added in v0.6.0

func Transport() http.RoundTripper

Transport returns a new http.RoundTripper with default settings applied.

Types

type DefaultLayout added in v0.6.0

type DefaultLayout struct {
	Path string
	Join func(...string) string
}

DefaultLayout implements the default layout for local and sftp backends, as described in the Design document. The `data` directory has one level of subdirs, two characters each (taken from the first two characters of the file name).

func (*DefaultLayout) Basedir added in v0.6.0

func (l *DefaultLayout) Basedir(t restic.FileType) string

Basedir returns the base dir name for type t.

func (*DefaultLayout) Dirname added in v0.6.0

func (l *DefaultLayout) Dirname(h restic.Handle) string

Dirname returns the directory path for a given file type and name.

func (*DefaultLayout) Filename added in v0.6.0

func (l *DefaultLayout) Filename(h restic.Handle) string

Filename returns a path to a file, including its name.

func (*DefaultLayout) Name added in v0.7.0

func (l *DefaultLayout) Name() string

Name returns the name for this layout.

func (*DefaultLayout) Paths added in v0.6.0

func (l *DefaultLayout) Paths() (dirs []string)

Paths returns all directory names needed for a repo.

func (*DefaultLayout) String added in v0.7.0

func (l *DefaultLayout) String() string

type Filesystem added in v0.6.0

type Filesystem interface {
	Join(...string) string
	ReadDir(string) ([]os.FileInfo, error)
	IsNotExist(error) bool
}

Filesystem is the abstraction of a file system used for a backend.

type Layout added in v0.6.0

type Layout interface {
	Filename(restic.Handle) string
	Dirname(restic.Handle) string
	Basedir(restic.FileType) string
	Paths() []string
	Name() string
}

Layout computes paths for file name storage.

func DetectLayout added in v0.6.0

func DetectLayout(repo Filesystem, dir string) (Layout, error)

DetectLayout tries to find out which layout is used in a local (or sftp) filesystem at the given path. If repo is nil, an instance of LocalFilesystem is used.

func ParseLayout added in v0.6.0

func ParseLayout(repo Filesystem, layout, defaultLayout, path string) (l Layout, err error)

ParseLayout parses the config string and returns a Layout. When layout is the empty string, DetectLayout is used. If that fails, defaultLayout is used.

type LimitedReadCloser added in v0.4.0

type LimitedReadCloser struct {
	io.ReadCloser
	io.Reader
}

LimitedReadCloser wraps io.LimitedReader and exposes the Close() method.

func LimitReadCloser added in v0.4.0

func LimitReadCloser(r io.ReadCloser, n int64) *LimitedReadCloser

LimitReadCloser returns a new reader wraps r in an io.LimitReader, but also exposes the Close() method.

func (*LimitedReadCloser) Read added in v0.4.0

func (l *LimitedReadCloser) Read(p []byte) (int, error)

Read reads data from the limited reader.

type LocalFilesystem added in v0.6.0

type LocalFilesystem struct {
}

LocalFilesystem implements Filesystem in a local path.

func (*LocalFilesystem) IsNotExist added in v0.6.0

func (l *LocalFilesystem) IsNotExist(err error) bool

IsNotExist returns true for errors that are caused by not existing files.

func (*LocalFilesystem) Join added in v0.6.0

func (l *LocalFilesystem) Join(paths ...string) string

Join combines several path components to one.

func (*LocalFilesystem) ReadDir added in v0.6.0

func (l *LocalFilesystem) ReadDir(dir string) ([]os.FileInfo, error)

ReadDir returns all entries of a directory.

type RESTLayout added in v0.6.0

type RESTLayout struct {
	URL  string
	Path string
	Join func(...string) string
}

RESTLayout implements the default layout for the REST protocol.

func (*RESTLayout) Basedir added in v0.6.0

func (l *RESTLayout) Basedir(t restic.FileType) string

Basedir returns the base dir name for files of type t.

func (*RESTLayout) Dirname added in v0.6.0

func (l *RESTLayout) Dirname(h restic.Handle) string

Dirname returns the directory path for a given file type and name.

func (*RESTLayout) Filename added in v0.6.0

func (l *RESTLayout) Filename(h restic.Handle) string

Filename returns a path to a file, including its name.

func (*RESTLayout) Name added in v0.7.0

func (l *RESTLayout) Name() string

Name returns the name for this layout.

func (*RESTLayout) Paths added in v0.6.0

func (l *RESTLayout) Paths() (dirs []string)

Paths returns all directory names

func (*RESTLayout) String added in v0.7.0

func (l *RESTLayout) String() string

type S3LegacyLayout added in v0.6.0

type S3LegacyLayout struct {
	URL  string
	Path string
	Join func(...string) string
}

S3LegacyLayout implements the old layout used for s3 cloud storage backends, as described in the Design document.

func (*S3LegacyLayout) Basedir added in v0.6.0

func (l *S3LegacyLayout) Basedir(t restic.FileType) string

Basedir returns the base dir name for type t.

func (*S3LegacyLayout) Dirname added in v0.6.0

func (l *S3LegacyLayout) Dirname(h restic.Handle) string

Dirname returns the directory path for a given file type and name.

func (*S3LegacyLayout) Filename added in v0.6.0

func (l *S3LegacyLayout) Filename(h restic.Handle) string

Filename returns a path to a file, including its name.

func (*S3LegacyLayout) Name added in v0.7.0

func (l *S3LegacyLayout) Name() string

Name returns the name for this layout.

func (*S3LegacyLayout) Paths added in v0.6.0

func (l *S3LegacyLayout) Paths() (dirs []string)

Paths returns all directory names

func (*S3LegacyLayout) String added in v0.7.0

func (l *S3LegacyLayout) String() string

type Semaphore added in v0.7.0

type Semaphore struct {
	// contains filtered or unexported fields
}

Semaphore limits access to a restricted resource.

func NewSemaphore added in v0.7.0

func NewSemaphore(n uint) (*Semaphore, error)

NewSemaphore returns a new semaphore with capacity n.

func (*Semaphore) GetToken added in v0.7.0

func (s *Semaphore) GetToken()

GetToken blocks until a Token is available.

func (*Semaphore) ReleaseToken added in v0.7.0

func (s *Semaphore) ReleaseToken()

ReleaseToken returns a token.

Directories

Path Synopsis
Package local implements repository storage in a local directory.
Package local implements repository storage in a local directory.
Package location implements parsing the restic repository location from a string.
Package location implements parsing the restic repository location from a string.
Package sftp implements repository storage in a directory on a remote server via the sftp protocol.
Package sftp implements repository storage in a directory on a remote server via the sftp protocol.
Package test contains a test suite with benchmarks for restic backends.
Package test contains a test suite with benchmarks for restic backends.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL