Documentation ¶
Overview ¶
Package tarsnap is a library interface to the tarsnap command-line tool.
Index ¶
- type Archive
- type Archives
- type Config
- func (c *Config) CacheTag() (string, error)
- func (c *Config) Create(name string, opts CreateOptions) error
- func (c *Config) Delete(archives ...string) error
- func (c *Config) Entries(name string, f func(*Entry) error) (err error)
- func (c *Config) Extract(name string, opts ExtractOptions) error
- func (c *Config) List() (Archives, error)
- func (c *Config) RC() (RC, error)
- func (c *Config) Size(archives ...string) (*SizeInfo, error)
- type CreateOptions
- type Entry
- type ExtractOptions
- type Flag
- type RC
- type Rule
- type SizeInfo
- type Sizes
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Archive ¶
type Archive struct { Name string `json:"name"` // base.tag Base string `json:"base,omitempty"` // base alone Tag string `json:"tag,omitempty"` // .tag alone Created time.Time `json:"created,omitempty"` // in UTC }
An Archive represents the name and metadata known about an archive.
type Archives ¶
type Archives []Archive
Archives is a sortable slice of Archive values, ordered non-decreasing by creation time with ties broken by name.
func (Archives) Latest ¶
Latest returns the most recently-created archive with the given base. It is shorthand for LatestAsOf(base, time.Now()).
func (Archives) LatestAsOf ¶
LatestAsOf returns the most recently-created archive with the given base at or before the specified time.
type Config ¶
type Config struct { Tool string `json:"tool"` Keyfile string `json:"keyFile"` WorkDir string `json:"workDir"` CacheDir string `json:"cacheDir"` // Optional settings flags to pass to the tarsnap command-line tool. Flags []Flag `json:"flags"` // If not nil, this function is called with each tarsnap command-line giving // the full argument list. CmdLog func(cmd string, args []string) `json:"-" yaml:"-"` }
Config carries configuration settings to a tarsnap execution. A nil *Config is ready for use and provides default settings.
func (*Config) CacheTag ¶ added in v0.0.19
CacheTag loads and returns the current cache sequence tag. If no cache directory is found, it returns "", nil.
func (*Config) Create ¶
func (c *Config) Create(name string, opts CreateOptions) error
Create creates an archive with the specified name and options. It is equivalent in effect to "tarsnap -c -f name opts...".
func (*Config) Entries ¶ added in v0.1.1
Entries calls f with each entry stored in the specified archive. If f reports an error, scanning stops and that error is returned to the caller of contents.
func (*Config) Extract ¶
func (c *Config) Extract(name string, opts ExtractOptions) error
Extract extracts from an archive with the specified name and options. It is equivalent in effect to "tarsnap -x -f name opts...".
func (*Config) List ¶
List returns a list of the known archives. The resulting slice is ordered nondecreasing by creation time and by name.
type CreateOptions ¶
type CreateOptions struct { // Include these files or directories in the archive. // N.B. The tarsnap tool does not expand globs in include paths. Include []string `json:"include"` // Change to this directory before adding entries. WorkDir string `json:"workDir,omitempty"` // Modify names by these patterns, /old/new/[gps]. Modify []string `json:"modify,omitempty"` // Exclude files or directories matching these glob patterns. Exclude []string `json:"exclude,omitempty"` // Follow symlinks (as tarsnap -H), storing the target rather than the link. FollowSymlinks bool `json:"followSymlinks" yaml:"follow-symlinks"` // Store access times (as tarsnap --store-atime). Not advised. StoreAccessTime bool `json:"storeAccessTime" yaml:"store-access-time"` // Preserve original pathnames (as tarsnap -P). PreservePaths bool `json:"preservePaths" yaml:"preserve-paths"` // If non-zero, set the creation time of the archive to this time. CreationTime time.Time `json:"creationTime,omitempty" yaml:"creation-time"` // Simulate creating archives rather than creating them. DryRun bool `json:"dryRun,omitempty" yaml:"dry-run"` }
CreateOptions control the creation of archives.
type Entry ¶ added in v0.1.0
type Entry struct { Mode os.FileMode Owner, Group int Size int64 // in bytes ModTime time.Time // in UTC Name string }
An Entry describes a single file or directory entry stored in an archive.
type ExtractOptions ¶
type ExtractOptions struct { // Include files matching these globs in the output. If this is empty, the // whole archive is extracted except for any exclusions. If not, only the // files or directories specified are extracted, modulo exclusions. Include []string `json:"include"` // Exclude files or directories matching these patterns. Exclude []string `json:"exclude,omitempty"` // Change to this directory before extracting entries. WorkDir string `json:"workDir,omitempty"` // Restore permissions, owner, flags, and ACL. RestorePermissions bool `json:"restorePerms" yaml:"restore-perms"` // Ignore owner and group settings from the archive. IgnoreOwners bool `json:"ignoreOwners" yaml:"ignore-owners"` // Stop reading after the first match for each included path. FastRead bool `json:"fastRead" yaml:"fast-read"` // Resume an incomplete previous extraction, skipping files that already // match by size and timestamp in the destination. Resume bool `json:"resume" yaml:"resume"` }
ExtractOptions control the extraction of archives.
type Flag ¶ added in v0.3.0
type Flag struct { Match string // if non-empty, only add if this argument is present Flag string // the name of the flag, passed as --name // If not nil, the value of a flag must be a string, float64, or bool. // A string value will have environment variables ($VAR) expanded. // // If value is nil or true, the flag has no argument: --name // If value is false, the flag is sent as: --no-name // Otherwise the flag is sent as: --name value Value interface{} }
A Flag describes a command-line flag for a tarsnap execution.
type RC ¶ added in v0.0.18
An RC represents a collection of tarsnap configuration settings.
func LoadRC ¶ added in v0.0.18
LoadRC reads the contents of the specified RC files, parses and merges them in the order specified. If one of the paths is not found, it is skipped without error. If no paths are specified, an empty RC is returned without error.
type Rule ¶
type Rule struct {
// contains filtered or unexported fields
}
A Rule is a path substitution rule, as defined for the "-s" flag of the tarsnap command-line tool.
type SizeInfo ¶
type SizeInfo struct { All *Sizes // sizes for all archives known Archive map[string]*Sizes // sizes for individual archives }
SizeInfo records storage size information for archives.
type Sizes ¶
type Sizes struct { // Total bytes of original input InputBytes int64 `json:"inputBytes"` // Size after input compression CompressedBytes int64 `json:"compressedBytes"` // Size after deduplication UniqueBytes int64 `json:"uniqueBytes"` // Size after deduplication and compression CompressedUniqueBytes int64 `json:"compressedUniqueBytes"` }
Sizes represents storage size values.