restic

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AWSAccessKeyID     = "AWS_ACCESS_KEY_ID"
	AWSSecretAccessKey = "AWS_SECRET_ACCESS_KEY"
	ResticPassword     = "RESTIC_PASSWORD"
	ResticRepository   = "RESTIC_REPOSITORY"
	ResticCommand      = "restic"
	// DeleteDataOutputSpaceFreed is the key for the output reporting the space freed
	DeleteDataOutputSpaceFreed = "spaceFreed"

	PasswordIncorrect = "password is incorrect"
	RepoDoesNotExist  = "repo does not exist"
	RepoBucket        = "open-local"
)
View Source
const (
	PhaseOpString = "###Phase-output###:"
)

Variables

This section is empty.

Functions

func BackupCommandByID

func BackupCommandByID(s3Endpoint, ak, sk, repository, encryptionKey, clusterID, pathToBackup string) string

BackupCommandByID returns restic backup command

func BackupCommandByTag

func BackupCommandByTag(s3Endpoint, ak, sk, repository, encryptionKey, clusterID, backupTag, includePath string) string

BackupCommandByTag returns restic backup command with tag

func DoesRepoExist

func DoesRepoExist(output string) bool

DoesRepoExists checks if repo exists from Snapshot Command log

func ForgetCommandByTag

func ForgetCommandByTag(s3Endpoint, ak, sk, repository, encryptionKey, clusterID, tag string) string

ForgetCommandByTag returns restic forget command

func GeneratePassword

func GeneratePassword() string

GeneratePassword generates a password

func InitCommand

func InitCommand(s3Endpoint, ak, sk, repository, encryptionKey, clusterID string) string

func IsPasswordIncorrect

func IsPasswordIncorrect(output string) bool

IsPasswordIncorrect checks if password was wrong from Snapshot Command log

func LatestSnapshotsCommand

func LatestSnapshotsCommand(s3Endpoint, ak, sk, repository, encryptionKey, clusterID string) string

func ParseResticSizeStringBytes

func ParseResticSizeStringBytes(sizeStr string) int64

ParseResticSizeStringBytes parses size strings as formatted by restic to a int64 number of bytes

func PruneCommand

func PruneCommand(s3Endpoint, ak, sk, repository, encryptionKey, clusterID string) string

PruneCommand returns restic prune command

func RestoreCommandByID

func RestoreCommandByID(s3Endpoint, ak, sk, repository, encryptionKey, clusterID, id, restorePath string) string

RestoreCommandByID returns restic restore command with snapshotID as the identifier

func RestoreCommandByTag

func RestoreCommandByTag(s3Endpoint, ak, sk, repository, encryptionKey, clusterID, tag, restorePath string) string

RestoreCommandByTag returns restic restore command with tag as the identifier

func SnapshotIDFromBackupLog

func SnapshotIDFromBackupLog(output string) string

SnapshotIDFromBackupLog gets the SnapshotID from Backup Command log

func SnapshotIDFromSnapshotLog

func SnapshotIDFromSnapshotLog(output string) ([]string, error)

SnapshotIDFromSnapshotLog gets the SnapshotID from Snapshot Command log

func SnapshotStatsFromBackupLog

func SnapshotStatsFromBackupLog(output string) (fileCount string, backupSize string, phySize string)

SnapshotStatsFromBackupLog gets the Snapshot file count and size from Backup Command log

func SnapshotsCommand

func SnapshotsCommand(s3Endpoint, ak, sk, repository, encryptionKey, clusterID string) string

SnapshotsCommand returns restic snapshots command

func SnapshotsCommandByTag

func SnapshotsCommandByTag(s3Endpoint, ak, sk, repository, encryptionKey, clusterID, tag string) string

SnapshotsCommandByTag returns restic snapshots command

func SpaceFreedFromPruneLog

func SpaceFreedFromPruneLog(output string) string

SpaceFreedFromPruneLog gets the space freed from the prune log output For reference, here is the logging command from restic codebase:

	Verbosef("will delete %d packs and rewrite %d packs, this frees %s\n",
              len(removePacks), len(rewritePacks), formatBytes(uint64(removeBytes)))

Types

type Output

type Output struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

func Parse

func Parse(l string) (*Output, error)

func UnmarshalOutput

func UnmarshalOutput(opString string) (*Output, error)

UnmarshalOutput unmarshals output json into Output struct

type ResticClient

type ResticClient struct {
	// contains filtered or unexported fields
}

func NewResticClient

func NewResticClient(s3Endpoint, ak, sk, encryptionKey string, kubeclient kubernetes.Interface) (*ResticClient, error)

申请 restic client 要求必须传入 repository

func (*ResticClient) BackupData

func (r *ResticClient) BackupData(repository, pathToBackup, backupTag string, updateEventFunc func(float64)) (int64, error)

func (*ResticClient) CheckIfRepoIsReachable

func (r *ResticClient) CheckIfRepoIsReachable(repository string) error

CheckIfRepoIsReachable checks if repo can be reached by trying to list snapshots

func (*ResticClient) CheckSnapshotExist

func (r *ResticClient) CheckSnapshotExist(repository string) (bool, error)

func (*ResticClient) DeleteDataByTag

func (r *ResticClient) DeleteDataByTag(repository string, deleteTag string, reclaimSpace bool) (map[string]interface{}, error)

func (*ResticClient) GetOrCreateRepository

func (r *ResticClient) GetOrCreateRepository(repository string) error

GetOrCreateRepository will check if the repository already exists and initialize one if not

func (*ResticClient) PruneData

func (r *ResticClient) PruneData(repository string) (string, error)

func (*ResticClient) RestoreData

func (r *ResticClient) RestoreData(repository, pathToRestore, backupTag string) (map[string]interface{}, error)

Jump to

Keyboard shortcuts

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