Documentation ¶
Index ¶
- Constants
- type BackupOptions
- type BackupOutput
- type BackupSummary
- type Command
- type DumpOptions
- type FileStats
- type ForgetGroup
- type HostBackupPhase
- type HostBackupStats
- type HostRestorePhase
- type HostRestoreStats
- type KeyOptions
- type RepositoryStats
- type ResticWrapper
- func (w *ResticWrapper) AddKey(opt KeyOptions) error
- func (w *ResticWrapper) Copy() *ResticWrapper
- func (w *ResticWrapper) DeleteSnapshots(snapshotIDs []string) ([]byte, error)
- func (w *ResticWrapper) DownloadSnapshot(options RestoreOptions) error
- func (w *ResticWrapper) Dump(dumpOptions DumpOptions) (*RestoreOutput, error)
- func (w *ResticWrapper) DumpEnv(path string, dumpedFile string) error
- func (w *ResticWrapper) DumpOnce(dumpOptions DumpOptions) ([]byte, error)
- func (w *ResticWrapper) GetCaPath() string
- func (w *ResticWrapper) GetEnv(key string) string
- func (w *ResticWrapper) GetRepo() string
- func (w *ResticWrapper) GetSnapshotSize(snapshotID string) (uint64, error)
- func (w *ResticWrapper) HideCMD()
- func (w *ResticWrapper) InitializeRepository() error
- func (w *ResticWrapper) ListKey() error
- func (w *ResticWrapper) ListSnapshots(snapshotIDs []string) ([]Snapshot, error)
- func (w *ResticWrapper) ParallelDump(dumpOptions []DumpOptions, maxConcurrency int) (*RestoreOutput, error)
- func (w *ResticWrapper) RemoveKey(opt KeyOptions) error
- func (w *ResticWrapper) RepositoryAlreadyExist() bool
- func (w *ResticWrapper) RunBackup(backupOption BackupOptions) (*BackupOutput, error)
- func (w *ResticWrapper) RunParallelBackup(backupOptions []BackupOptions, maxConcurrency int) (*BackupOutput, error)
- func (w *ResticWrapper) RunRestore(restoreOptions RestoreOptions) (*RestoreOutput, error)
- func (w *ResticWrapper) SetEnv(key, value string)
- func (w *ResticWrapper) UnlockRepository() error
- func (w *ResticWrapper) UpdateKey(opt KeyOptions) error
- func (w *ResticWrapper) VerifyRepositoryIntegrity() (*RepositoryStats, error)
- type RestoreOptions
- type RestoreOutput
- type SetupOptions
- type Snapshot
- type SnapshotStats
- type StatsContainer
Constants ¶
const ( DefaultOutputFileName = "output.json" DefaultScratchDir = "/tmp" DefaultHost = "host-0" )
const ( RESTIC_REPOSITORY = "RESTIC_REPOSITORY" RESTIC_PASSWORD = "RESTIC_PASSWORD" RESTIC_PROGRESS_FPS = "RESTIC_PROGRESS_FPS" TMPDIR = "TMPDIR" AWS_ACCESS_KEY_ID = "AWS_ACCESS_KEY_ID" AWS_SECRET_ACCESS_KEY = "AWS_SECRET_ACCESS_KEY" AWS_DEFAULT_REGION = "AWS_DEFAULT_REGION" GOOGLE_PROJECT_ID = "GOOGLE_PROJECT_ID" GOOGLE_SERVICE_ACCOUNT_JSON_KEY = "GOOGLE_SERVICE_ACCOUNT_JSON_KEY" GOOGLE_APPLICATION_CREDENTIALS = "GOOGLE_APPLICATION_CREDENTIALS" AZURE_ACCOUNT_NAME = "AZURE_ACCOUNT_NAME" AZURE_ACCOUNT_KEY = "AZURE_ACCOUNT_KEY" REST_SERVER_USERNAME = "REST_SERVER_USERNAME" REST_SERVER_PASSWORD = "REST_SERVER_PASSWORD" B2_ACCOUNT_ID = "B2_ACCOUNT_ID" B2_ACCOUNT_KEY = "B2_ACCOUNT_KEY" // For keystone v1 authentication ST_AUTH = "ST_AUTH" ST_USER = "ST_USER" ST_KEY = "ST_KEY" // For keystone v2 authentication (some variables are optional) OS_AUTH_URL = "OS_AUTH_URL" OS_REGION_NAME = "OS_REGION_NAME" OS_USERNAME = "OS_USERNAME" OS_PASSWORD = "OS_PASSWORD" OS_TENANT_ID = "OS_TENANT_ID" OS_TENANT_NAME = "OS_TENANT_NAME" // For keystone v3 authentication (some variables are optional) OS_USER_DOMAIN_NAME = "OS_USER_DOMAIN_NAME" OS_PROJECT_NAME = "OS_PROJECT_NAME" OS_PROJECT_DOMAIN_NAME = "OS_PROJECT_DOMAIN_NAME" // For keystone v3 application credential authentication (application credential id) OS_APPLICATION_CREDENTIAL_ID = "OS_APPLICATION_CREDENTIAL_ID" OS_APPLICATION_CREDENTIAL_SECRET = "OS_APPLICATION_CREDENTIAL_SECRET" // For keystone v3 application credential authentication (application credential name) OS_APPLICATION_CREDENTIAL_NAME = "OS_APPLICATION_CREDENTIAL_NAME" // For authentication based on tokens OS_STORAGE_URL = "OS_STORAGE_URL" OS_AUTH_TOKEN = "OS_AUTH_TOKEN" // For using certs in Minio server or REST server CA_CERT_DATA = "CA_CERT_DATA" )
const FileModeRWXAll = 0o777
const (
ResticCMD = "restic"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BackupOptions ¶
type BackupOptions struct { Host string BackupPaths []string StdinPipeCommands []Command StdinFileName string // default "stdin" Exclude []string Args []string }
BackupOptions specifies backup information if StdinPipeCommands is specified, BackupPaths will not be used
type BackupOutput ¶ added in v0.2.0
type BackupOutput struct { // Stats shows statistics of individual hosts Stats []HostBackupStats `json:"stats,omitempty"` }
type BackupSummary ¶
type BackupSummary struct { MessageType string `json:"message_type"` // "summary" FilesNew *int64 `json:"files_new"` FilesChanged *int64 `json:"files_changed"` FilesUnmodified *int64 `json:"files_unmodified"` DataAdded uint64 `json:"data_added"` TotalFilesProcessed *int64 `json:"total_files_processed"` TotalBytesProcessed uint64 `json:"total_bytes_processed"` TotalDuration float64 `json:"total_duration"` // in seconds SnapshotID string `json:"snapshot_id"` }
type DumpOptions ¶
type FileStats ¶
type FileStats struct { // TotalFiles shows total number of files that has been backed up TotalFiles *int64 `json:"totalFiles,omitempty"` // NewFiles shows total number of new files that has been created since last backup NewFiles *int64 `json:"newFiles,omitempty"` // ModifiedFiles shows total number of files that has been modified since last backup ModifiedFiles *int64 `json:"modifiedFiles,omitempty"` // UnmodifiedFiles shows total number of files that has not been changed since last backup UnmodifiedFiles *int64 `json:"unmodifiedFiles,omitempty"` }
type ForgetGroup ¶
type ForgetGroup struct { Keep []json.RawMessage `json:"keep"` Remove []json.RawMessage `json:"remove"` }
type HostBackupPhase ¶
type HostBackupPhase string
const ( HostBackupSucceeded HostBackupPhase = "Succeeded" HostBackupFailed HostBackupPhase = "Failed" )
type HostBackupStats ¶
type HostBackupStats struct { // Hostname indicate name of the host that has been backed up // +optional Hostname string `json:"hostname,omitempty"` // Phase indicates backup phase of this host // +optional Phase HostBackupPhase `json:"phase,omitempty"` // Snapshots specifies the stats of individual snapshots that has been taken for this host in current backup session // +optional Snapshots []SnapshotStats `json:"snapshots,omitempty"` // Duration indicates total time taken to complete backup for this hosts // +optional Duration string `json:"duration,omitempty"` // Error indicates string value of error in case of backup failure // +optional Error string `json:"error,omitempty"` }
type HostRestorePhase ¶
type HostRestorePhase string
const ( HostRestoreSucceeded HostRestorePhase = "Succeeded" HostRestoreFailed HostRestorePhase = "Failed" )
type HostRestoreStats ¶
type HostRestoreStats struct { // Hostname indicate name of the host that has been restored // +optional Hostname string `json:"hostname,omitempty"` // Phase indicates restore phase of this host // +optional Phase HostRestorePhase `json:"phase,omitempty"` // Duration indicates total time taken to complete restore for this hosts // +optional Duration string `json:"duration,omitempty"` // Error indicates string value of error in case of restore failure // +optional Error string `json:"error,omitempty"` }
type KeyOptions ¶ added in v0.2.0
type RepositoryStats ¶
type RepositoryStats struct { // Integrity shows result of repository integrity check after last backup Integrity *bool `json:"integrity,omitempty"` // Size show size of repository after last backup Size string `json:"size,omitempty"` // SnapshotCount shows number of snapshots stored in the repository SnapshotCount int64 `json:"snapshotCount,omitempty"` // SnapshotsRemovedOnLastCleanup shows number of old snapshots cleaned up according to retention policy on last backup session SnapshotsRemovedOnLastCleanup int64 `json:"snapshotsRemovedOnLastCleanup,omitempty"` }
type ResticWrapper ¶
type ResticWrapper struct {
// contains filtered or unexported fields
}
func NewResticWrapper ¶
func NewResticWrapper(options SetupOptions) (*ResticWrapper, error)
func NewResticWrapperFromShell ¶
func NewResticWrapperFromShell(options SetupOptions, sh *shell.Session) (*ResticWrapper, error)
func (*ResticWrapper) AddKey ¶ added in v0.2.0
func (w *ResticWrapper) AddKey(opt KeyOptions) error
func (*ResticWrapper) Copy ¶
func (w *ResticWrapper) Copy() *ResticWrapper
Copy function copy input ResticWrapper and returns a new wrapper with copy of its content.
func (*ResticWrapper) DeleteSnapshots ¶
func (w *ResticWrapper) DeleteSnapshots(snapshotIDs []string) ([]byte, error)
func (*ResticWrapper) DownloadSnapshot ¶ added in v0.2.0
func (w *ResticWrapper) DownloadSnapshot(options RestoreOptions) error
func (*ResticWrapper) Dump ¶
func (w *ResticWrapper) Dump(dumpOptions DumpOptions) (*RestoreOutput, error)
Dump run restore process for a single host and output the restored files in stdout.
func (*ResticWrapper) DumpEnv ¶
func (w *ResticWrapper) DumpEnv(path string, dumpedFile string) error
func (*ResticWrapper) DumpOnce ¶ added in v0.2.0
func (w *ResticWrapper) DumpOnce(dumpOptions DumpOptions) ([]byte, error)
func (*ResticWrapper) GetCaPath ¶
func (w *ResticWrapper) GetCaPath() string
func (*ResticWrapper) GetEnv ¶
func (w *ResticWrapper) GetEnv(key string) string
func (*ResticWrapper) GetRepo ¶
func (w *ResticWrapper) GetRepo() string
func (*ResticWrapper) GetSnapshotSize ¶
func (w *ResticWrapper) GetSnapshotSize(snapshotID string) (uint64, error)
GetSnapshotSize returns size of a snapshot in bytes
func (*ResticWrapper) HideCMD ¶
func (w *ResticWrapper) HideCMD()
func (*ResticWrapper) InitializeRepository ¶
func (w *ResticWrapper) InitializeRepository() error
func (*ResticWrapper) ListKey ¶ added in v0.2.0
func (w *ResticWrapper) ListKey() error
func (*ResticWrapper) ListSnapshots ¶
func (w *ResticWrapper) ListSnapshots(snapshotIDs []string) ([]Snapshot, error)
func (*ResticWrapper) ParallelDump ¶
func (w *ResticWrapper) ParallelDump(dumpOptions []DumpOptions, maxConcurrency int) (*RestoreOutput, error)
ParallelDump run DumpOnce for multiple hosts concurrently using go routine. You can control maximum number of parallel restore process using maxConcurrency parameter.
func (*ResticWrapper) RemoveKey ¶ added in v0.2.0
func (w *ResticWrapper) RemoveKey(opt KeyOptions) error
func (*ResticWrapper) RepositoryAlreadyExist ¶
func (w *ResticWrapper) RepositoryAlreadyExist() bool
func (*ResticWrapper) RunBackup ¶
func (w *ResticWrapper) RunBackup(backupOption BackupOptions) (*BackupOutput, error)
RunBackup takes backup, cleanup old snapshots, check repository integrity etc. It extracts valuable information from respective restic command it runs and return them for further use.
func (*ResticWrapper) RunParallelBackup ¶ added in v0.2.0
func (w *ResticWrapper) RunParallelBackup(backupOptions []BackupOptions, maxConcurrency int) (*BackupOutput, error)
RunParallelBackup runs multiple backup in parallel. Host must be different for each backup.
func (*ResticWrapper) RunRestore ¶
func (w *ResticWrapper) RunRestore(restoreOptions RestoreOptions) (*RestoreOutput, error)
RunRestore run restore process for a single host.
func (*ResticWrapper) SetEnv ¶
func (w *ResticWrapper) SetEnv(key, value string)
func (*ResticWrapper) UnlockRepository ¶
func (w *ResticWrapper) UnlockRepository() error
func (*ResticWrapper) UpdateKey ¶ added in v0.2.0
func (w *ResticWrapper) UpdateKey(opt KeyOptions) error
func (*ResticWrapper) VerifyRepositoryIntegrity ¶
func (w *ResticWrapper) VerifyRepositoryIntegrity() (*RepositoryStats, error)
type RestoreOptions ¶
type RestoreOptions struct { Host string SourceHost string RestorePaths []string Snapshots []string // when Snapshots are specified SourceHost and RestorePaths will not be used Destination string // destination path where snapshot will be restored, used in cli Exclude []string Include []string Args []string }
RestoreOptions specifies restore information
type RestoreOutput ¶
type RestoreOutput struct { // Stats shows restore statistics of individual hosts Stats []HostRestoreStats `json:"stats,omitempty"` }
type SetupOptions ¶
type SetupOptions struct { MaxConnections int64 EncryptionSecret *kmapi.ObjectReference Directory string Client client.Client BackupStorage *kmapi.ObjectReference CacertFile string ScratchDir string MountPath string EnableCache bool Nice *ofst.NiceSettings IONice *ofst.IONiceSettings // contains filtered or unexported fields }
type SnapshotStats ¶
type SnapshotStats struct { // Name indicates the name of the backup snapshot created for this host Name string `json:"name,omitempty"` // Path indicates the directory that has been backed up in this snapshot Path string `json:"path,omitempty"` // TotalSize indicates the size of data to backup in target directory TotalSize string `json:"totalSize,omitempty"` // Uploaded indicates size of data uploaded to backend for this snapshot Uploaded string `json:"uploaded,omitempty"` // ProcessingTime indicates time taken to process the target data ProcessingTime string `json:"processingTime,omitempty"` // FileStats shows statistics of files of this snapshot FileStats FileStats `json:"fileStats,omitempty"` }
type StatsContainer ¶
type StatsContainer struct {
TotalSize uint64 `json:"total_size"`
}