Documentation ¶
Index ¶
- Constants
- Variables
- func BlobList(cmdArgs BlobListCommandArgs) []string
- func BlobStats(cmdArgs BlobStatsCommandArgs) []string
- func ErrorsFromOutput(output string) []error
- func ExecKopiaArgs(configFilePath string) []string
- func FileLogLevel() string
- func GeneralCommand(cmdArgs GeneralCommandArgs) logsafe.Cmd
- func GetCacheSizeSettingsForRestore() (contentCacheMB, metadataCacheMB int)
- func GetCacheSizeSettingsForSnapshot() (contentCacheMB, metadataCacheMB int)
- func GetEnvOrDefault(name, def string) string
- func GetGeneralCacheSizeSettings() (contentCacheMB, metadataCacheMB int)
- func GetPolicyModifications() map[string]string
- func IsEqualSnapshotCreateStats(a, b *SnapshotCreateStats) bool
- func LatestSnapshotInfoFromManifestList(output string) (string, string, error)
- func LogLevel() string
- func MaintenanceInfo(cmdArgs MaintenanceInfoCommandArgs) []string
- func MaintenanceRunCommand(cmdArgs MaintenanceRunCommandArgs) []string
- func MaintenanceSetOwner(cmdArgs MaintenanceSetOwnerCommandArgs) []string
- func NonEmptyOrDefault[T comparable](t T, def T) T
- func ParsePolicyShow(output string) (policy.Policy, error)
- func ParseSnapshotManifestList(output string) ([]*snapshot.Manifest, error)
- func PolicySetGlobal(cmdArgs PolicySetGlobalCommandArgs) []string
- func PolicyShowGlobal(cmdArgs PolicyShowGlobalCommandArgs) []string
- func RepoSizeStatsFromBlobStatsRaw(blobStats string) (phySizeTotal int64, blobCount int, err error)
- func RepositoryConnectCommand(cmdArgs RepositoryCommandArgs) ([]string, error)
- func RepositoryConnectServerCommand(cmdArgs RepositoryServerCommandArgs) []string
- func RepositoryCreateCommand(cmdArgs RepositoryCommandArgs) ([]string, error)
- func RepositorySetParametersCommand(cmdArgs RepositorySetParametersCommandArgs) []string
- func RepositoryStatusCommand(cmdArgs RepositoryStatusCommandArgs) []string
- func Restore(cmdArgs RestoreCommandArgs) []string
- func ServerAddUser(cmdArgs ServerAddUserCommandArgs) []string
- func ServerListUser(cmdArgs ServerListUserCommmandArgs) []string
- func ServerRefresh(cmdArgs ServerRefreshCommandArgs) []string
- func ServerSetUser(cmdArgs ServerSetUserCommandArgs) []string
- func ServerStart(cmdArgs ServerStartCommandArgs) []string
- func ServerStatus(cmdArgs ServerStatusCommandArgs) []string
- func SnapListAll(cmdArgs SnapListAllCommandArgs) []string
- func SnapListAllWithSnapIDs(cmdArgs SnapListAllWithSnapIDsCommandArgs) []string
- func SnapListByTags(cmdArgs SnapListByTagsCommandArgs) []string
- func SnapSizeStatsFromSnapListAll(output string) (totalSizeB int64, numSnapshots int, err error)
- func SnapshotCreate(cmdArgs SnapshotCreateCommandArgs) []string
- func SnapshotDelete(cmdArgs SnapshotDeleteCommandArgs) []string
- func SnapshotExpire(cmdArgs SnapshotExpireCommandArgs) []string
- func SnapshotIDsFromSnapshot(output string) (snapID, rootID string, err error)
- func SnapshotInfoFromSnapshotCreateOutput(output string) (string, string, error)
- func SnapshotRestore(cmdArgs SnapshotRestoreCommandArgs) []string
- func SnapshotVerify(cmdArgs SnapshotVerifyCommandArgs) []string
- type BlobListCommandArgs
- type BlobStatsCommandArgs
- type CacheArgs
- type CommandArgs
- type GeneralCommandArgs
- type MaintenanceInfoCommandArgs
- type MaintenanceRunCommandArgs
- type MaintenanceSetOwnerCommandArgs
- type PolicySetGlobalCommandArgs
- type PolicyShowGlobalCommandArgs
- type RepositoryCommandArgs
- type RepositoryServerCommandArgs
- type RepositorySetParametersCommandArgs
- type RepositoryStatusCommandArgs
- type RestoreCommandArgs
- type RestoreStats
- type ServerAddUserCommandArgs
- type ServerListUserCommmandArgs
- type ServerRefreshCommandArgs
- type ServerSetUserCommandArgs
- type ServerStartCommandArgs
- type ServerStatusCommandArgs
- type SnapListAllCommandArgs
- type SnapListAllWithSnapIDsCommandArgs
- type SnapListByTagsCommandArgs
- type SnapshotCreateCommandArgs
- type SnapshotCreateInfo
- type SnapshotCreateStats
- type SnapshotDeleteCommandArgs
- type SnapshotExpireCommandArgs
- type SnapshotRestoreCommandArgs
- type SnapshotVerifyCommandArgs
Constants ¶
const ( // LogLevelVarName is the environment variable that controls datastore log level. LogLevelVarName = "DATA_STORE_LOG_LEVEL" // FileLogLevelVarName is the environment variable that controls datastore file log level. FileLogLevelVarName = "DATA_STORE_FILE_LOG_LEVEL" )
const ( LogLevelError = "error" LogLevelInfo = "info" )
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" // DefaultHtpasswdFilePath is the path to the generated htpasswd file DefaultHtpasswdFilePath = "/tmp/kopia-htpasswd" )
Constants for kopia defaults
Variables ¶
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 ¶
ErrorsFromOutput parses the output of a kopia and returns an error, if found
func ExecKopiaArgs ¶
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 GetEnvOrDefault ¶
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 IsEqualSnapshotCreateStats ¶
func IsEqualSnapshotCreateStats(a, b *SnapshotCreateStats) bool
func LatestSnapshotInfoFromManifestList ¶
LatestSnapshotInfoFromManifestList returns snapshot ID and backup path of the latest snapshot from `manifests list` output
func LogLevel ¶
func LogLevel() string
LogLevel will return either value from env or "error" as default value
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 NonEmptyOrDefault ¶
func NonEmptyOrDefault[T comparable](t T, def T) T
func ParsePolicyShow ¶
ParsePolicyShow parses the output of a kopia policy show command.
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 ¶
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 RepositorySetParametersCommand ¶
func RepositorySetParametersCommand(cmdArgs RepositorySetParametersCommandArgs) []string
RepositorySetParametersCommand to cover https://kopia.io/docs/reference/command-line/common/repository-set-parameters/
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 ¶
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 ¶
SnapshotIDsFromSnapshot extracts root ID of a snapshot from the logs
func SnapshotInfoFromSnapshotCreateOutput ¶
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
func SnapshotVerify ¶
func SnapshotVerify(cmdArgs SnapshotVerifyCommandArgs) []string
SnapshotVerify returns kopia command verifying snapshots with given snapshot IDs.
Types ¶
type BlobListCommandArgs ¶
type BlobListCommandArgs struct {
*CommandArgs
}
type BlobStatsCommandArgs ¶
type BlobStatsCommandArgs struct {
*CommandArgs
}
type CacheArgs ¶
CacheArgs has fields that can be used to set cache settings for different kopia repository operations
type CommandArgs ¶
type GeneralCommandArgs ¶
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 Parallelism int }
type RestoreStats ¶
type RestoreStats struct { FilesProcessed int64 SizeProcessedB int64 FilesTotal int64 SizeTotalB int64 ProgressPercent int64 }
RestoreStats is a container for stats parsed from the output of a `kopia restore` command.
func RestoreStatsFromRestoreOutput ¶
func RestoreStatsFromRestoreOutput( restoreStderrOutput string, ) (stats *RestoreStats)
RestoreStatsFromRestoreOutput parses the output of a `kopia restore` line-by-line in search of progress statistics. It returns nil if no statistics are found, or the most recent statistic if multiple are encountered.
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 CacheArgs CacheDirectory string ServerAddress string TLSCertFile string TLSKeyFile string ServerUsername string ServerPassword string HtpasswdFilePath string ReadOnly bool 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 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` line-by-line in search of progress statistics. It returns nil if no statistics are found, or the most recent statistic if multiple are encountered.
type SnapshotDeleteCommandArgs ¶
type SnapshotDeleteCommandArgs struct { *CommandArgs SnapID string }
type SnapshotExpireCommandArgs ¶
type SnapshotExpireCommandArgs struct { *CommandArgs RootID string MustDelete bool }