Documentation
¶
Overview ¶
Package sftp implements repository storage in a directory on a remote server via the sftp protocol.
Index ¶
- func Join(parts ...string) string
- func ParseConfig(s string) (interface{}, error)
- func SplitShellArgs(data string) (cmd string, args []string, err error)
- type Config
- type SFTP
- func (r *SFTP) Close() error
- func (r *SFTP) Delete(context.Context) error
- func (r *SFTP) IsNotExist(err error) bool
- func (r *SFTP) Join(p ...string) string
- func (r *SFTP) List(ctx context.Context, t restic.FileType) <-chan string
- func (r *SFTP) Load(ctx context.Context, h restic.Handle, length int, offset int64) (io.ReadCloser, error)
- func (r *SFTP) Location() string
- func (r *SFTP) ReadDir(dir string) ([]os.FileInfo, error)
- func (r *SFTP) Remove(ctx context.Context, h restic.Handle) error
- func (r *SFTP) Save(ctx context.Context, h restic.Handle, rd io.Reader) (err error)
- func (r *SFTP) Stat(ctx context.Context, h restic.Handle) (restic.FileInfo, error)
- func (r *SFTP) Test(ctx context.Context, h restic.Handle) (bool, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Join ¶
Join joins the given paths and cleans them afterwards. This always uses forward slashes, which is required by sftp.
func ParseConfig ¶
ParseConfig parses the string s and extracts the sftp config. The supported configuration formats are sftp://user@host/directory
and sftp:user@host:directory. The directory will be path Cleaned and can be an absolute path if it starts with a '/' (e.g. sftp://user@host//absolute and sftp:user@host:/absolute).
Types ¶
type Config ¶
type Config struct {
User, Host, Path string
Layout string `option:"layout" help:"use this backend directory layout (default: auto-detect)"`
Command string `option:"command" help:"specify command to create sftp connection"`
}
Config collects all information required to connect to an sftp server.
type SFTP ¶
SFTP is a backend in a directory accessed via SFTP.
func Create ¶
Create creates an sftp backend as described by the config by running "ssh" with the appropriate arguments (or cfg.Command, if set). The function preExec is run just before, postExec just after starting a program.
func Open ¶
Open opens an sftp backend as described by the config by running "ssh" with the appropriate arguments (or cfg.Command, if set). The function preExec is run just before, postExec just after starting a program.
func (*SFTP) IsNotExist ¶
IsNotExist returns true if the error is caused by a not existing file.
func (*SFTP) List ¶
List returns a channel that yields all names of blobs of type t. A goroutine is started for this. If the channel done is closed, sending stops.
func (*SFTP) Load ¶
func (r *SFTP) Load(ctx context.Context, h restic.Handle, length int, offset int64) (io.ReadCloser, error)
Load returns a reader that yields the contents of the file at h at the given offset. If length is nonzero, only a portion of the file is returned. rd must be closed after use.