Documentation
¶
Overview ¶
Package restore manages restoring filesystem snapshots.
Index ¶
- Constants
- func PathIfPlaceholder(path string) string
- func SafeRemoveAll(path string) error
- func SafelySuffixablePath(path string) bool
- type FileWriteProgress
- type FilesystemOutput
- func (o *FilesystemOutput) BeginDirectory(ctx context.Context, relativePath string, _ fs.Directory) error
- func (o *FilesystemOutput) Close(_ context.Context) error
- func (o *FilesystemOutput) CreateSymlink(ctx context.Context, relativePath string, e fs.Symlink) error
- func (o *FilesystemOutput) FileExists(_ context.Context, relativePath string, e fs.File) bool
- func (o *FilesystemOutput) FinishDirectory(_ context.Context, relativePath string, e fs.Directory) error
- func (o *FilesystemOutput) Init(ctx context.Context) error
- func (o *FilesystemOutput) Parallelizable() bool
- func (o *FilesystemOutput) SymlinkExists(ctx context.Context, relativePath string, e fs.Symlink) bool
- func (o *FilesystemOutput) WriteDirEntry(ctx context.Context, relativePath string, de *snapshot.DirEntry, ...) error
- func (o *FilesystemOutput) WriteFile(ctx context.Context, relativePath string, f fs.File, ...) error
- type Options
- type Output
- type ProgressCallback
- type ShallowFilesystemOutput
- type Stats
- type TarOutput
- func (o *TarOutput) BeginDirectory(_ context.Context, relativePath string, d fs.Directory) error
- func (o *TarOutput) Close(_ context.Context) error
- func (o *TarOutput) CreateSymlink(ctx context.Context, relativePath string, l fs.Symlink) error
- func (o *TarOutput) FileExists(ctx context.Context, relativePath string, f fs.File) bool
- func (o *TarOutput) FinishDirectory(ctx context.Context, relativePath string, e fs.Directory) error
- func (o *TarOutput) Parallelizable() bool
- func (o *TarOutput) SymlinkExists(ctx context.Context, relativePath string, l fs.Symlink) bool
- func (o *TarOutput) WriteDirEntry(ctx context.Context, relativePath string, de *snapshot.DirEntry, ...) error
- func (o *TarOutput) WriteFile(ctx context.Context, relativePath string, f fs.File, _ FileWriteProgress) error
- type ZipOutput
- func (o *ZipOutput) BeginDirectory(ctx context.Context, relativePath string, e fs.Directory) error
- func (o *ZipOutput) Close(_ context.Context) error
- func (o *ZipOutput) CreateSymlink(ctx context.Context, relativePath string, e fs.Symlink) error
- func (o *ZipOutput) FileExists(ctx context.Context, relativePath string, l fs.File) bool
- func (o *ZipOutput) FinishDirectory(ctx context.Context, relativePath string, e fs.Directory) error
- func (o *ZipOutput) Parallelizable() bool
- func (o *ZipOutput) SymlinkExists(ctx context.Context, relativePath string, l fs.Symlink) bool
- func (o *ZipOutput) WriteDirEntry(ctx context.Context, relativePath string, de *snapshot.DirEntry, ...) error
- func (o *ZipOutput) WriteFile(ctx context.Context, relativePath string, f fs.File, _ FileWriteProgress) error
Constants ¶
const MaxFilenameLength = syscall.NAME_MAX
MaxFilenameLength is the maximum length of a filename.
Variables ¶
This section is empty.
Functions ¶
func PathIfPlaceholder ¶ added in v0.9.0
PathIfPlaceholder returns the placeholder suffix trimmed from path or the empty string if path is not a placeholder file.
func SafeRemoveAll ¶ added in v0.9.0
SafeRemoveAll removes the shallow placeholder file(s) for path if they exist without experiencing errors caused by long file names.
func SafelySuffixablePath ¶ added in v0.9.0
SafelySuffixablePath returns true if path can be suffixed with the placeholder suffix and written to the filesystem.
Types ¶
type FileWriteProgress ¶ added in v0.18.0
type FileWriteProgress func(chunkSize int64)
FileWriteProgress is a callback used to report amount of data sent to the output.
type FilesystemOutput ¶
type FilesystemOutput struct {
// TargetPath for restore.
TargetPath string `json:"targetPath"`
// If a directory already exists, overwrite the directory.
OverwriteDirectories bool `json:"overwriteDirectories"`
// Indicate whether or not to overwrite existing files. When set to false,
// the copier does not modify already existing files and returns an error
// instead.
OverwriteFiles bool `json:"overwriteFiles"`
// If a symlink already exists, remove it and create a new one. When set to
// false, the copier does not modify existing symlinks and will return an
// error instead.
OverwriteSymlinks bool `json:"overwriteSymlinks"`
// IgnorePermissionErrors causes restore to ignore errors due to invalid permissions.
IgnorePermissionErrors bool `json:"ignorePermissionErrors"`
// When set to true, first write to a temp file and rename it, to ensure there are no partially written files in case of a crash.
WriteFilesAtomically bool `json:"writeFilesAtomically"`
// SkipOwners when set to true causes restore to skip restoring owner information.
SkipOwners bool `json:"skipOwners"`
// SkipPermissions when set to true causes restore to skip restoring permission information.
SkipPermissions bool `json:"skipPermissions"`
// SkipTimes when set to true causes restore to skip restoring modification times.
SkipTimes bool `json:"skipTimes"`
// WriteSparseFiles when set to true, write contents as sparse files, minimizing allocated disk space.
WriteSparseFiles bool `json:"writeSparseFiles"`
// Indicate whether or not flush files after restore.
// Varying from OS, the copier may write the file data to the system cache,
// so the data may not be written to disk when the restore to the file completes.
// This flag guarantees the file data is flushed to disk.
FlushFiles bool `json:"flushFiles"`
// contains filtered or unexported fields
}
FilesystemOutput contains the options for outputting a file system tree.
func (*FilesystemOutput) BeginDirectory ¶
func (o *FilesystemOutput) BeginDirectory(ctx context.Context, relativePath string, _ fs.Directory) error
BeginDirectory implements restore.Output interface.
func (*FilesystemOutput) Close ¶
func (o *FilesystemOutput) Close(_ context.Context) error
Close implements restore.Output interface.
func (*FilesystemOutput) CreateSymlink ¶
func (o *FilesystemOutput) CreateSymlink(ctx context.Context, relativePath string, e fs.Symlink) error
CreateSymlink implements restore.Output interface.
func (*FilesystemOutput) FileExists ¶ added in v0.8.0
FileExists implements restore.Output interface.
func (*FilesystemOutput) FinishDirectory ¶
func (o *FilesystemOutput) FinishDirectory(_ context.Context, relativePath string, e fs.Directory) error
FinishDirectory implements restore.Output interface.
func (*FilesystemOutput) Init ¶ added in v0.11.0
func (o *FilesystemOutput) Init(ctx context.Context) error
Init initializes the internal members of the filesystem writer output. This method must be called before FilesystemOutput can be used.
func (*FilesystemOutput) Parallelizable ¶ added in v0.7.3
func (o *FilesystemOutput) Parallelizable() bool
Parallelizable implements restore.Output interface.
func (*FilesystemOutput) SymlinkExists ¶ added in v0.8.0
func (o *FilesystemOutput) SymlinkExists(ctx context.Context, relativePath string, e fs.Symlink) bool
SymlinkExists implements restore.Output interface.
func (*FilesystemOutput) WriteDirEntry ¶ added in v0.9.0
func (o *FilesystemOutput) WriteDirEntry(ctx context.Context, relativePath string, de *snapshot.DirEntry, e fs.Directory) error
WriteDirEntry implements restore.Output interface.
func (*FilesystemOutput) WriteFile ¶
func (o *FilesystemOutput) WriteFile(ctx context.Context, relativePath string, f fs.File, progressCb FileWriteProgress) error
WriteFile implements restore.Output interface.
type Options ¶ added in v0.7.3
type Options struct {
// NOTE: this structure is passed as-is from the UI, make sure to add
// required bindings in the UI.
Parallel int `json:"parallel"`
Incremental bool `json:"incremental"`
DeleteExtra bool `json:"deleteExtra"`
IgnoreErrors bool `json:"ignoreErrors"`
RestoreDirEntryAtDepth int32 `json:"restoreDirEntryAtDepth"`
MinSizeForPlaceholder int32 `json:"minSizeForPlaceholder"`
ProgressCallback ProgressCallback `json:"-"`
Cancel chan struct{} `json:"-"` // channel that can be externally closed to signal cancellation
}
Options provides optional restore parameters.
type Output ¶
type Output interface {
Parallelizable() bool
BeginDirectory(ctx context.Context, relativePath string, e fs.Directory) error
WriteDirEntry(ctx context.Context, relativePath string, de *snapshot.DirEntry, e fs.Directory) error
FinishDirectory(ctx context.Context, relativePath string, e fs.Directory) error
WriteFile(ctx context.Context, relativePath string, e fs.File, progressCb FileWriteProgress) error
FileExists(ctx context.Context, relativePath string, e fs.File) bool
CreateSymlink(ctx context.Context, relativePath string, e fs.Symlink) error
SymlinkExists(ctx context.Context, relativePath string, e fs.Symlink) bool
Close(ctx context.Context) error
}
Output encapsulates output for restore operation.
type ProgressCallback ¶ added in v0.18.0
ProgressCallback is a callback used to report progress of snapshot restore.
type ShallowFilesystemOutput ¶ added in v0.9.0
type ShallowFilesystemOutput struct {
FilesystemOutput
// Files smaller than this will be written directly as part of the restore.
MinSizeForPlaceholder int32
}
ShallowFilesystemOutput overrides methods in FilesystemOutput with shallow versions.
func (*ShallowFilesystemOutput) WriteDirEntry ¶ added in v0.9.0
func (o *ShallowFilesystemOutput) WriteDirEntry(ctx context.Context, relativePath string, de *snapshot.DirEntry, e fs.Directory) error
WriteDirEntry implements restore.Output interface.
func (*ShallowFilesystemOutput) WriteFile ¶ added in v0.9.0
func (o *ShallowFilesystemOutput) WriteFile(ctx context.Context, relativePath string, f fs.File, _ FileWriteProgress) error
WriteFile implements restore.Output interface.
type Stats ¶
type Stats struct {
RestoredTotalFileSize int64
EnqueuedTotalFileSize int64
SkippedTotalFileSize int64
RestoredFileCount int32
RestoredDirCount int32
RestoredSymlinkCount int32
EnqueuedFileCount int32
EnqueuedDirCount int32
EnqueuedSymlinkCount int32
SkippedCount int32
DeletedFilesCount int32
DeletedSymlinkCount int32
DeletedDirCount int32
IgnoredErrorCount int32
}
Stats represents restore statistics.
type TarOutput ¶
type TarOutput struct {
// contains filtered or unexported fields
}
TarOutput contains the options for outputting a file system tree to a tar or .tar.gz file.
func NewTarOutput ¶
func NewTarOutput(w io.WriteCloser) *TarOutput
NewTarOutput creates new tar writer output.
func (*TarOutput) BeginDirectory ¶
BeginDirectory implements restore.Output interface.
func (*TarOutput) CreateSymlink ¶
CreateSymlink implements restore.Output interface.
func (*TarOutput) FileExists ¶ added in v0.8.0
FileExists implements restore.Output interface.
func (*TarOutput) FinishDirectory ¶
FinishDirectory implements restore.Output interface.
func (*TarOutput) Parallelizable ¶ added in v0.7.3
Parallelizable implements restore.Output interface.
func (*TarOutput) SymlinkExists ¶ added in v0.8.0
SymlinkExists implements restore.Output interface.
type ZipOutput ¶
type ZipOutput struct {
// contains filtered or unexported fields
}
ZipOutput contains the options for outputting a file system tree to a zip file.
func NewZipOutput ¶
func NewZipOutput(w io.WriteCloser, method uint16) *ZipOutput
NewZipOutput creates new zip writer output.
func (*ZipOutput) BeginDirectory ¶
BeginDirectory implements restore.Output interface.
func (*ZipOutput) CreateSymlink ¶
CreateSymlink implements restore.Output interface.
func (*ZipOutput) FileExists ¶ added in v0.8.0
FileExists implements restore.Output interface.
func (*ZipOutput) FinishDirectory ¶
FinishDirectory implements restore.Output interface.
func (*ZipOutput) Parallelizable ¶ added in v0.7.3
Parallelizable implements restore.Output interface.
func (*ZipOutput) SymlinkExists ¶ added in v0.8.0
SymlinkExists implements restore.Output interface.