command

package
v0.0.0-...-778623d Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LogLevelError = "error"
	LogLevelInfo  = "info"
)
View Source
const (
	// DefaultCacheDirectory is the directory where kopia content cache is created
	DefaultCacheDirectory = "/tmp/kopia-cache"

	// DefaultConfigFilePath is the file which contains kopia repo config
	DefaultConfigFilePath = "/tmp/kopia-repository.config"

	// DefaultConfigDirectory is the directory which contains custom kopia repo config
	DefaultConfigDirectory = "/tmp/kopia-repository"

	// DefaultLogDirectory is the directory where kopia log file is created
	DefaultLogDirectory = "/tmp/kopia-log"
)

Constants for kopia defaults

Variables

View Source
var ANSIEscapeCode = regexp.MustCompile(`\x1b[^m]*?m`)

Functions

func BlobList

func BlobList(cmdArgs BlobListCommandArgs) []string

BlobList returns the kopia command for listing blobs in the repository with their sizes

func BlobStats

func BlobStats(cmdArgs BlobStatsCommandArgs) []string

BlobStats returns the kopia command to get the blob stats

func ErrorsFromOutput

func ErrorsFromOutput(output string) []error

ErrorFromOutput parses the output of a kopia and returns an error, if found

func ExecKopiaArgs

func ExecKopiaArgs(configFilePath string) []string

ExecKopiaArgs returns the basic Argv for executing kopia with the given config file path.

func GeneralCommand

func GeneralCommand(cmdArgs GeneralCommandArgs) logsafe.Cmd

GeneralCommand returns the kopia command contains subcommands, loggable flags, loggable key value pairs and redacted key value pairs

func GetCacheSizeSettingsForRestore

func GetCacheSizeSettingsForRestore() (contentCacheMB, metadataCacheMB int)

GetCacheSizeSettingsForRestore returns the feature setting cache size values to be used for initializing repositories that will be performing restore workloads

func GetCacheSizeSettingsForSnapshot

func GetCacheSizeSettingsForSnapshot() (contentCacheMB, metadataCacheMB int)

GetCacheSizeSettingsForSnapshot returns the feature setting cache size values to be used for initializing repositories that will be performing general command workloads that benefit from cacheing metadata only.

func GetGeneralCacheSizeSettings

func GetGeneralCacheSizeSettings() (contentCacheMB, metadataCacheMB int)

GetGeneralCacheSizeSettings returns the feature setting cache size values to be used for initializing repositories that will be performing general command workloads that benefit from cacheing metadata only.

func GetPolicyModifications

func GetPolicyModifications() map[string]string

func IsEqualSnapshotCreateStats

func IsEqualSnapshotCreateStats(a, b *SnapshotCreateStats) bool

func LatestSnapshotInfoFromManifestList

func LatestSnapshotInfoFromManifestList(output string) (string, string, error)

LatestSnapshotInfoFromManifestList returns snapshot ID and backup path of the latest snapshot from `manifests list` output

func MaintenanceInfo

func MaintenanceInfo(cmdArgs MaintenanceInfoCommandArgs) []string

MaintenanceInfo returns the kopia command to get maintenance info

func MaintenanceRunCommand

func MaintenanceRunCommand(cmdArgs MaintenanceRunCommandArgs) []string

MaintenanceRunCommand returns the kopia command to run manual maintenance

func MaintenanceSetOwner

func MaintenanceSetOwner(cmdArgs MaintenanceSetOwnerCommandArgs) []string

MaintenanceSetOwner returns the kopia command for setting custom maintenance owner

func ParsePolicyShow

func ParsePolicyShow(output string) (policy.Policy, error)

ParsePolicyShow parses the output of a kopia policy show command.

func ParseSnapshotManifestList

func ParseSnapshotManifestList(output string) ([]*snapshot.Manifest, error)

func PolicySetGlobal

func PolicySetGlobal(cmdArgs PolicySetGlobalCommandArgs) []string

PolicySetGlobal returns the kopia command for modifying the global policy

func PolicyShowGlobal

func PolicyShowGlobal(cmdArgs PolicyShowGlobalCommandArgs) []string

PolicyShowGlobal returns the kopia command for showing the global policy.

func RepoSizeStatsFromBlobStatsRaw

func RepoSizeStatsFromBlobStatsRaw(blobStats string) (phySizeTotal int64, blobCount int, err error)

RepoSizeStatsFromBlobStatsRaw takes a string as input, interprets it as a kopia blob stats output in an expected format (Contains the line "Total: <size>"), and returns the integer size in bytes or an error if parsing is unsuccessful.

func RepositoryConnectCommand

func RepositoryConnectCommand(cmdArgs RepositoryCommandArgs) ([]string, error)

RepositoryConnectCommand returns the kopia command for connecting to an existing repo

func RepositoryConnectServerCommand

func RepositoryConnectServerCommand(cmdArgs RepositoryServerCommandArgs) []string

RepositoryConnectServerCommand returns the kopia command for connecting to a remote repository on Kopia Repository API server

func RepositoryCreateCommand

func RepositoryCreateCommand(cmdArgs RepositoryCommandArgs) ([]string, error)

RepositoryCreateCommand returns the kopia command for creation of a repo

func RepositoryStatusCommand

func RepositoryStatusCommand(cmdArgs RepositoryStatusCommandArgs) []string

RepositoryStatusCommand returns the kopia command for checking status of the Kopia repository

func Restore

func Restore(cmdArgs RestoreCommandArgs) []string

Restore returns the kopia command for restoring root of a snapshot with given root ID

func ServerAddUser

func ServerAddUser(cmdArgs ServerAddUserCommandArgs) []string

ServerAddUser returns the kopia command adding a new user to the Kopia API Server

func ServerListUser

func ServerListUser(cmdArgs ServerListUserCommmandArgs) []string

ServerListUser returns the kopia command to list users from the Kopia API Server

func ServerRefresh

func ServerRefresh(cmdArgs ServerRefreshCommandArgs) []string

ServerRefresh returns the kopia command for refreshing the Kopia API Server This helps allow new users to be able to connect to the Server instead of waiting for auto-refresh

func ServerSetUser

func ServerSetUser(cmdArgs ServerSetUserCommandArgs) []string

ServerSetUser returns the kopia command setting password for existing user for the Kopia API Server

func ServerStart

func ServerStart(cmdArgs ServerStartCommandArgs) []string

ServerStart returns the kopia command for starting the Kopia API Server

func ServerStatus

func ServerStatus(cmdArgs ServerStatusCommandArgs) []string

ServerStatus returns the kopia command for checking status of the Kopia API Server

func SnapListAll

func SnapListAll(cmdArgs SnapListAllCommandArgs) []string

SnapListAll returns the kopia command for listing all snapshots in the repository with their sizes

func SnapListAllWithSnapIDs

func SnapListAllWithSnapIDs(cmdArgs SnapListAllWithSnapIDsCommandArgs) []string

SnapListAllWithSnapIDs returns the kopia command for listing all snapshots in the repository with snapshotIDs

func SnapListByTags

func SnapListByTags(cmdArgs SnapListByTagsCommandArgs) []string

func SnapSizeStatsFromSnapListAll

func SnapSizeStatsFromSnapListAll(output string) (totalSizeB int64, numSnapshots int, err error)

SnapSizeStatsFromSnapListAll returns a list of snapshot logical sizes assuming the input string is formatted as the output of a kopia snapshot list --all command.

func SnapshotCreate

func SnapshotCreate(cmdArgs SnapshotCreateCommandArgs) []string

SnapshotCreate returns the kopia command for creation of a snapshot

func SnapshotDelete

func SnapshotDelete(cmdArgs SnapshotDeleteCommandArgs) []string

SnapshotDelete returns the kopia command for deleting a snapshot with given snapshot ID

func SnapshotExpire

func SnapshotExpire(cmdArgs SnapshotExpireCommandArgs) []string

SnapshotExpire returns the kopia command for removing snapshots with given root ID

func SnapshotIDsFromSnapshot

func SnapshotIDsFromSnapshot(output string) (snapID, rootID string, err error)

SnapshotIDsFromSnapshot extracts root ID of a snapshot from the logs

func SnapshotInfoFromSnapshotCreateOutput

func SnapshotInfoFromSnapshotCreateOutput(output string) (string, string, error)

SnapshotInfoFromSnapshotCreateOutput returns snapshot ID and root ID from snapshot create output

func SnapshotRestore

func SnapshotRestore(cmdArgs SnapshotRestoreCommandArgs) []string

SnapshotRestore returns kopia command restoring snapshots with given snap ID

Types

type BlobListCommandArgs

type BlobListCommandArgs struct {
	*CommandArgs
}

type BlobStatsCommandArgs

type BlobStatsCommandArgs struct {
	*CommandArgs
}

type CacheArgs

type CacheArgs struct {
	ContentCacheLimitMB  int
	MetadataCacheLimitMB int
}

CacheArgs has fields that can be used to set cache settings for different kopia repository operations

type CommandArgs

type CommandArgs struct {
	RepoPassword   string
	ConfigFilePath string
	LogDirectory   string
	LogLevel       string
}

type GeneralCommandArgs

type GeneralCommandArgs struct {
	*CommandArgs
	SubCommands      []string
	LoggableFlag     []string
	LoggableKV       map[string]string
	RedactedKV       map[string]string
	OutputFileSuffix string
}

type MaintenanceInfoCommandArgs

type MaintenanceInfoCommandArgs struct {
	*CommandArgs
	GetJsonOutput bool
}

type MaintenanceRunCommandArgs

type MaintenanceRunCommandArgs struct {
	*CommandArgs
}

type MaintenanceSetOwnerCommandArgs

type MaintenanceSetOwnerCommandArgs struct {
	*CommandArgs
	CustomOwner string
}

type PolicySetGlobalCommandArgs

type PolicySetGlobalCommandArgs struct {
	*CommandArgs
	Modifications policyChanges
}

type PolicyShowGlobalCommandArgs

type PolicyShowGlobalCommandArgs struct {
	*CommandArgs
	GetJsonOutput bool
}

type RepositoryCommandArgs

type RepositoryCommandArgs struct {
	*CommandArgs
	CacheArgs
	CacheDirectory  string
	Hostname        string
	ContentCacheMB  int
	MetadataCacheMB int
	Username        string
	RepoPathPrefix  string
	ReadOnly        bool
	// Only for CreateCommand
	RetentionMode   string
	RetentionPeriod time.Duration
	// PITFlag is only effective if set while repository connect
	PITFlag  strfmt.DateTime
	Location map[string][]byte
}

RepositoryCommandArgs contains fields that are needed for creating or connecting to a Kopia repository

type RepositoryServerCommandArgs

type RepositoryServerCommandArgs struct {
	UserPassword   string
	ConfigFilePath string
	LogDirectory   string
	CacheDirectory string
	Hostname       string
	ServerURL      string
	Fingerprint    string
	Username       string
	ReadOnly       bool
	CacheArgs
}

RepositoryServerCommandArgs contains fields required for connecting to Kopia Repository API server

type RepositorySetParametersCommandArgs

type RepositorySetParametersCommandArgs struct {
	*CommandArgs
	RetentionMode   string
	RetentionPeriod time.Duration
}

type RepositoryStatusCommandArgs

type RepositoryStatusCommandArgs struct {
	*CommandArgs
	GetJsonOutput bool
}

type RestoreCommandArgs

type RestoreCommandArgs struct {
	*CommandArgs
	RootID                 string
	TargetPath             string
	IgnorePermissionErrors bool
}

type ServerAddUserCommandArgs

type ServerAddUserCommandArgs struct {
	*CommandArgs
	NewUsername  string
	UserPassword string
}

type ServerListUserCommmandArgs

type ServerListUserCommmandArgs struct {
	*CommandArgs
}

type ServerRefreshCommandArgs

type ServerRefreshCommandArgs struct {
	*CommandArgs
	ServerAddress  string
	ServerUsername string
	ServerPassword string
	Fingerprint    string
}

type ServerSetUserCommandArgs

type ServerSetUserCommandArgs struct {
	*CommandArgs
	NewUsername  string
	UserPassword string
}

type ServerStartCommandArgs

type ServerStartCommandArgs struct {
	*CommandArgs
	ServerAddress        string
	TLSCertFile          string
	TLSKeyFile           string
	ServerUsername       string
	ServerPassword       string
	AutoGenerateCert     bool
	Background           bool
	EnablePprof          bool
	MetricsListenAddress string
}

type ServerStatusCommandArgs

type ServerStatusCommandArgs struct {
	*CommandArgs
	ServerAddress  string
	ServerUsername string
	ServerPassword string
	Fingerprint    string
}

type SnapListAllCommandArgs

type SnapListAllCommandArgs struct {
	*CommandArgs
}

type SnapListAllWithSnapIDsCommandArgs

type SnapListAllWithSnapIDsCommandArgs struct {
	*CommandArgs
}

type SnapListByTagsCommandArgs

type SnapListByTagsCommandArgs struct {
	*CommandArgs
	Tags []string
}

type SnapshotCreateCommandArgs

type SnapshotCreateCommandArgs struct {
	*CommandArgs
	PathToBackup           string
	Tags                   []string
	ProgressUpdateInterval time.Duration
	Parallelism            int
}

type SnapshotCreateInfo

type SnapshotCreateInfo struct {
	SnapshotID string
	RootID     string
	Stats      *SnapshotCreateStats
}

SnapshotCreateInfo is a container for data that can be parsed from the output of `kopia snapshot create`.

func ParseSnapshotCreateOutput

func ParseSnapshotCreateOutput(snapCreateStdoutOutput, snapCreateStderrOutput string) (*SnapshotCreateInfo, error)

ParseSnapshotCreateOutput parses the output of a snapshot create command into a new SnapshotCreateInfo struct and returns its pointer. The Stats field may be nil if the stats were unable to be parsed. The root ID and snapshot ID are fetched from structured stdout and stats are parsed from stderr output.

type SnapshotCreateStats

type SnapshotCreateStats struct {
	FilesHashed     int64
	SizeHashedB     int64
	FilesCached     int64
	SizeCachedB     int64
	SizeUploadedB   int64
	SizeEstimatedB  int64
	ProgressPercent int64
}

SnapshotCreateStats is a container for stats parsed from the output of a `kopia snapshot create` command.

func SnapshotStatsFromSnapshotCreate

func SnapshotStatsFromSnapshotCreate(snapCreateStderrOutput string, matchOnlyFinished bool) (stats *SnapshotCreateStats)

SnapshotStatsFromSnapshotCreate parses the output of a kopia snapshot create execution for a log of the stats for that execution.

type SnapshotDeleteCommandArgs

type SnapshotDeleteCommandArgs struct {
	*CommandArgs
	SnapID string
}

type SnapshotExpireCommandArgs

type SnapshotExpireCommandArgs struct {
	*CommandArgs
	RootID     string
	MustDelete bool
}

type SnapshotRestoreCommandArgs

type SnapshotRestoreCommandArgs struct {
	*CommandArgs
	SnapID                 string
	TargetPath             string
	SparseRestore          bool
	IgnorePermissionErrors bool
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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