Documentation ¶
Index ¶
- Constants
- Variables
- func CustomLevelEncoder(level zapcore.Level, enc zapcore.PrimitiveArrayEncoder)
- func SyslogTimeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder)
- func WithHTTPClient(client *http.Client) func(*Client) error
- func WriteLog() (*zap.Logger, error)
- type Activity
- type AuthRestore
- type BackupDirectory
- type BackupDirectoryConfig
- type BackupDirectoryConfigPolicy
- type Client
- func (c *Client) ChunkFileToBackup(ctx context.Context, pool *ants.Pool, itemInfo *cache.Node, ...) (uint64, error)
- func (c *Client) CreateRecoveryPoint(ctx context.Context, backupDirectoryID string, ...) (*CreateRecoveryPointResponse, error)
- func (c *Client) DeleteRecoveryPoints(ctx context.Context, recoveryPointID string) error
- func (c *Client) Do(req *http.Request) (*http.Response, error)
- func (c *Client) GetBackupDirectory(id string) (*BackupDirectory, error)
- func (c *Client) GetConfig(ctx context.Context) (*Config, error)
- func (c *Client) GetCredentialStorageVault(storageVaultID string, actionID string, restoreKey *AuthRestore) (*StorageVault, error)
- func (c *Client) GetLatestRecoveryPointID(backupDirectoryID string) (*RecoveryPointResponse, error)
- func (c *Client) GetObject(storageVault storage_vault.StorageVault, key string, restoreKey *AuthRestore) ([]byte, error)
- func (c *Client) GetRecoveryPointInfo(recoveryPointID string) (*RecoveryPointResponse, error)
- func (c *Client) GetRestoreSessionKey(recoveryPointID string, actionID string, createdAt string) (*RestoreResponse, error)
- func (c *Client) LatestVersion() (*Version, error)
- func (c *Client) ListActivity(ctx context.Context, machineID string, statuses []string) (*ListActivity, error)
- func (c *Client) ListBackupDirectory() (*ListBackupDirectory, error)
- func (c *Client) ListRecoveryPoints(ctx context.Context, backupDirectoryID string) (*ListRecoveryPointsResponse, error)
- func (c *Client) NewRequest(method, relPath string, body interface{}) (*http.Request, error)
- func (c *Client) OpenFile(ctx context.Context, path string) (io.ReadCloser, error)
- func (c *Client) PutObject(storageVault storage_vault.StorageVault, key string, data []byte) error
- func (c *Client) RequestBackupDirectory(id string, cmbr *CreateManualBackupRequest) error
- func (c *Client) RequestRestore(recoveryPointID string, crr *CreateRestoreRequest) error
- func (c *Client) RestoreDirectory(ctx context.Context, index cache.Index, destDir string, ...) error
- func (c *Client) RestoreItem(ctx context.Context, destDir string, item cache.Node, ...) error
- func (c *Client) UpdateMachine() (*UpdateMachineResponse, error)
- func (c *Client) UploadFile(ctx context.Context, pool *ants.Pool, lastInfo *cache.Node, ...) (uint64, error)
- type ClientOption
- type Config
- type CreateManualBackupRequest
- type CreateRecoveryPointRequest
- type CreateRecoveryPointResponse
- type CreateRestoreRequest
- type Directories
- type ListActivity
- type ListBackupDirectory
- type ListRecoveryPointsResponse
- type Machine
- type Policy
- type PolicyDirectories
- type ProgressWriter
- type RecoveryPoint
- type RecoveryPointResponse
- type RestoreResponse
- type StorageVault
- type UpdateMachineResponse
- type UpdateRecoveryPointRequest
- type UpdateState
- type Version
Constants ¶
const ( ChunkUploadLowerBound = chunker.MaxSize IntervalTimeRetryChunk = 30 * time.Second MaxTimesRetryChunk = 3 )
const ( RecoveryPointTypePoint = "RECOVERY_POINT" RecoveryPointTypeInitialReplica = "INITIAL_REPLICA" RecoveryPointStatusCreated = "CREATED" RecoveryPointStatusCompleted = "COMPLETED" RecoveryPointStatusFAILED = "FAILED" )
Variables ¶
var ErrUpdateRecoveryPoint = errors.New("failed to update recovery point")
ErrUpdateRecoveryPoint indicates that there is error from server when updating recovery point.
var (
ErrorGotCancelRequest = errors.New("got cancel request")
)
Functions ¶
func CustomLevelEncoder ¶ added in v1.0.0
func CustomLevelEncoder(level zapcore.Level, enc zapcore.PrimitiveArrayEncoder)
func SyslogTimeEncoder ¶ added in v1.0.0
func SyslogTimeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder)
func WithHTTPClient ¶
WithHTTPClient sets the underlying HTTP client for Client.
Types ¶
type Activity ¶ added in v1.0.18
type Activity struct { ID string `json:"id"` Action string `json:"action"` Status string `json:"status"` Message string `json:"message"` BackupDirectoryID string `json:"backup_directory_id"` PolicyID string `json:"policy_id"` Progress string `json:"progress_restore"` RecoveryPoint RecoveryPoint `json:"recovery_point"` MachineID string `json:"machine_id"` CreatedAt string `json:"created_at"` UpdatedAt string `json:"updated_at"` }
Activity ...
type AuthRestore ¶ added in v1.0.0
type BackupDirectory ¶
type BackupDirectory struct { ID string `json:"id"` Name string `json:"name"` Description string `json:"description"` Path string `json:"path"` Quota int `json:"quota"` Size int `json:"size"` MachineID string `json:"machine_id"` TenantID string `json:"tenant_id"` }
BackupDirectory ...
type BackupDirectoryConfig ¶
type BackupDirectoryConfig struct { ID string `json:"id" yaml:"id"` Name string `json:"name" yaml:"name"` Path string `json:"path" yaml:"path"` Policies []BackupDirectoryConfigPolicy `json:"policies" yaml:"policies"` Activated bool `json:"activated" yaml:"activated"` }
BackupDirectoryConfig is the cron policies for given directory.
type BackupDirectoryConfigPolicy ¶
type BackupDirectoryConfigPolicy struct { ID string `json:"id" yaml:"id"` Name string `json:"name" yaml:"name"` SchedulePattern string `json:"schedule_pattern" yaml:"schedule_pattern"` Retentions string `json:"retentions" yaml:"retentions"` LimitUpload int `json:"limit_upload" yaml:"limit_upload"` }
BackupDirectoryConfigPolicy is the cron policy.
type Client ¶
Client is the client for interacting with BackupService API server.
func NewClient ¶
func NewClient(opts ...ClientOption) (*Client, error)
NewClient creates a Client with given options.
func (*Client) ChunkFileToBackup ¶ added in v1.0.0
func (*Client) CreateRecoveryPoint ¶
func (c *Client) CreateRecoveryPoint(ctx context.Context, backupDirectoryID string, crpr *CreateRecoveryPointRequest) (*CreateRecoveryPointResponse, error)
func (*Client) DeleteRecoveryPoints ¶ added in v1.0.20
DeleteRecoveryPoints delete a recovery points.
func (*Client) GetBackupDirectory ¶
func (c *Client) GetBackupDirectory(id string) (*BackupDirectory, error)
GetBackupDirectory retrieves a backup directory by given id.
func (*Client) GetCredentialStorageVault ¶ added in v1.0.0
func (c *Client) GetCredentialStorageVault(storageVaultID string, actionID string, restoreKey *AuthRestore) (*StorageVault, error)
GetCredentialStorageVault get a new credential with backend credential not constant.
func (*Client) GetLatestRecoveryPointID ¶ added in v1.0.0
func (c *Client) GetLatestRecoveryPointID(backupDirectoryID string) (*RecoveryPointResponse, error)
func (*Client) GetObject ¶ added in v1.0.0
func (c *Client) GetObject(storageVault storage_vault.StorageVault, key string, restoreKey *AuthRestore) ([]byte, error)
GetObject downloads the object by name in storage vault.
func (*Client) GetRecoveryPointInfo ¶ added in v1.0.0
func (c *Client) GetRecoveryPointInfo(recoveryPointID string) (*RecoveryPointResponse, error)
func (*Client) GetRestoreSessionKey ¶ added in v1.0.0
func (*Client) LatestVersion ¶ added in v0.0.11
func (*Client) ListActivity ¶ added in v1.0.18
func (c *Client) ListActivity(ctx context.Context, machineID string, statuses []string) (*ListActivity, error)
ListActivity retrieves list activity.
func (*Client) ListBackupDirectory ¶ added in v1.0.4
func (c *Client) ListBackupDirectory() (*ListBackupDirectory, error)
ListBackupDirectory retrieves list backup directory.
func (*Client) ListRecoveryPoints ¶
func (c *Client) ListRecoveryPoints(ctx context.Context, backupDirectoryID string) (*ListRecoveryPointsResponse, error)
ListRecoveryPoints list all recovery points of given backup directory.
func (*Client) NewRequest ¶
NewRequest create new http request
func (*Client) PutObject ¶ added in v1.0.0
func (c *Client) PutObject(storageVault storage_vault.StorageVault, key string, data []byte) error
PutObject stores the data to the storage vault.
func (*Client) RequestBackupDirectory ¶
func (c *Client) RequestBackupDirectory(id string, cmbr *CreateManualBackupRequest) error
RequestBackupDirectory requests a manual backup.
func (*Client) RequestRestore ¶
func (c *Client) RequestRestore(recoveryPointID string, crr *CreateRestoreRequest) error
RequestRestore requests restore
func (*Client) RestoreDirectory ¶ added in v1.0.0
func (c *Client) RestoreDirectory(ctx context.Context, index cache.Index, destDir string, storageVault storage_vault.StorageVault, restoreKey *AuthRestore, p *progress.Progress) error
func (*Client) RestoreItem ¶ added in v1.0.0
func (c *Client) RestoreItem(ctx context.Context, destDir string, item cache.Node, storageVault storage_vault.StorageVault, restoreKey *AuthRestore, p *progress.Progress) error
func (*Client) UpdateMachine ¶
func (c *Client) UpdateMachine() (*UpdateMachineResponse, error)
UpdateMachine updates machine information.
func (*Client) UploadFile ¶
type ClientOption ¶
ClientOption provides mechanism to configure Client.
func WithAccessKey ¶
func WithAccessKey(accessKey string) ClientOption
WithAccessKey sets the access key for Client.
func WithNumGoroutine ¶ added in v1.0.19
func WithNumGoroutine(num int) ClientOption
WithNumGoroutine sets the secret key for Client.
func WithSecretKey ¶
func WithSecretKey(secretKey string) ClientOption
WithSecretKey sets the secret key for Client.
func WithServerURL ¶
func WithServerURL(serverURL string) ClientOption
WithServerURL sets the server url for Client.
type Config ¶
type Config struct {
BackupDirectories []BackupDirectoryConfig `json:"backup_directories" yaml:"backup_directories"`
}
type CreateManualBackupRequest ¶
type CreateManualBackupRequest struct { Action string `json:"action"` StorageType string `json:"storage_type"` Name string `json:"name"` }
CreateManualBackupRequest represents a request manual backup.
type CreateRecoveryPointRequest ¶
type CreateRecoveryPointRequest struct { PolicyID string `json:"policy_id"` Name string `json:"name"` RecoveryPointType string `json:"recovery_point_type"` }
CreateRecoveryPointRequest represents a request to create a recovery point.
type CreateRecoveryPointResponse ¶
type CreateRecoveryPointResponse struct { ID string `json:"id"` RecoveryPoint *RecoveryPoint `json:"recovery_point"` Action string `json:"action"` Status string `json:"status"` StorageVault *StorageVault `json:"storage_vault"` }
CreateRecoveryPointResponse is the server response when creating recovery point
type CreateRestoreRequest ¶
CreateRestoreRequest represents a request manual backup.
type Directories ¶ added in v1.0.4
Directories ...
type ListActivity ¶ added in v1.0.18
type ListActivity struct {
Activities []Activity `json:"activities"`
}
ListBackupDirectory ...
type ListBackupDirectory ¶ added in v1.0.4
type ListBackupDirectory struct {
Directories []BackupDirectory `json:"directories"`
}
ListBackupDirectory ...
type ListRecoveryPointsResponse ¶ added in v1.0.4
type ListRecoveryPointsResponse struct {
RecoveryPoints []RecoveryPointResponse `json:"recovery_points"`
}
ListRecoveryPointsResponse get a list recovery point of backup directory id
type Machine ¶
type Machine struct { ID string `json:"id"` CreatedAt string `json:"created_at"` UpdatedAt string `json:"updated_at"` Name string `json:"name"` HostName string `json:"host_name"` IPAddress string `json:"ip_address"` OSVersion string `json:"os_version"` AgentVersion string `json:"agent_version"` TenantID string `json:"tenant_id"` OSMachineID string `json:"os_machine_id"` NumGoroutine int `json:"num_goroutine"` }
Machine ...
type Policy ¶
type Policy struct { ID string `json:"id"` Name string `json:"name"` SchedulePattern string `json:"schedule_pattern"` RetentionHours int `json:"retention_hours"` RetentionDays int `json:"retention_days"` RetentionWeeks int `json:"retention_weeks"` RetentionMonths int `json:"retention_months"` CreatedAt string `json:"created_at"` UpdatedAt string `json:"updated_at"` TenantID string `json:"tenant_id"` }
Policy ...
type PolicyDirectories ¶
type PolicyDirectories struct { ID string `json:"id"` Name string `json:"name"` SchedulePattern string `json:"schedule_pattern"` RetentionHours int `json:"retention_hours"` RetentionDays int `json:"retention_days"` RetentionWeeks int `json:"retention_weeks"` RetentionMonths int `json:"retention_months"` CreatedAt string `json:"created_at"` UpdatedAt string `json:"updated_at"` TenantID string `json:"tenant_id"` BackupDirectories []string `json:"backup-directories"` }
PolicyDirectories ...
type ProgressWriter ¶
type ProgressWriter struct {
// contains filtered or unexported fields
}
ProgressWriter wraps a writer, counts number of bytes written to it and write the report back to writer.
func NewProgressWriter ¶
func NewProgressWriter(out io.Writer) *ProgressWriter
NewProgressWriter returns new progress writer.
type RecoveryPoint ¶
type RecoveryPoint struct { ID string `json:"id"` Name string `json:"name"` RecoveryPointType string `json:"recovery_point_type"` Status string `json:"status"` PolicyID string `json:"policy_id"` Progress string `json:"progress"` BackupDirectoryID string `json:"backup_directory_id"` CreatedAt string `json:"created_at"` UpdatedAt string `json:"updated_at"` }
RecoveryPoint ...
type RecoveryPointResponse ¶ added in v1.0.0
type RecoveryPointResponse struct { Name string `json:"name"` RecoveryPointType string `json:"recovery_point_type"` ID string `json:"id"` Status string `json:"status"` CreatedAt string `json:"created_at"` UpdatedAt string `json:"updated_at"` IndexHash string `json:"index_hash"` }
LatestRecoveryPointID get a id latest recovery point of backup directory id.
type RestoreResponse ¶ added in v1.0.0
type StorageVault ¶ added in v1.0.0
type StorageVault struct { ID string `json:"id"` Name string `json:"name"` CredentialType string `json:"credential_type"` StorageBucket string `json:"storage_bucket"` StorageVaultType string `json:"storage_vault_type"` SecretRef string `json:"secret_ref"` CreatedAt string `json:"created_at"` UpdatedAt string `json:"updated_at"` Deleted bool `json:"deleted"` EncryptionKey string `json:"encryption_key"` Credential storage_vault.Credential `json:"credential"` }
StorageVault ...
type UpdateMachineResponse ¶ added in v0.0.2
type UpdateMachineResponse struct { BrokerUrl string `json:"broker_url"` NumGoroutine int `json:"num_goroutine"` }
UpdateMachineResponse is the server response when update machine info
type UpdateRecoveryPointRequest ¶
type UpdateRecoveryPointRequest struct {
Status string `json:"status"`
}
UpdateRecoveryPointRequest represents a request to update a recovery point.
type UpdateState ¶ added in v1.0.4
type UpdateState struct { EventType string `json:"event_type"` Directories []Directories `json:"directories"` }
UpdateState ...