Documentation
¶
Index ¶
- func ClearPendingReports()
- func SavePendingReport(report JobReportRequest)
- type ApiResponse
- type Client
- func (c *Client) Deregister(ctx context.Context) error
- func (c *Client) FlushPendingReports(ctx context.Context)
- func (c *Client) GetLatestVersion(ctx context.Context) (*VersionInfo, error)
- func (c *Client) GetPendingBackups(ctx context.Context) ([]PendingBackup, error)
- func (c *Client) GetPendingFileDumps(ctx context.Context) ([]PendingFileDump, error)
- func (c *Client) GetPendingRestores(ctx context.Context) ([]PendingRestore, error)
- func (c *Client) GetRepos(ctx context.Context) ([]RepoConfig, bool, error)
- func (c *Client) PostDockerVolumes(ctx context.Context, data interface{}) error
- func (c *Client) ReportJob(ctx context.Context, req JobReportRequest) error
- func (c *Client) ReportProgress(ctx context.Context, progress ProgressReport)
- func (c *Client) SendHeartbeat(ctx context.Context, req HeartbeatRequest) (*HeartbeatResponse, error)
- func (c *Client) ShipLogs(ctx context.Context, lines []string) error
- func (c *Client) UploadFileDump(ctx context.Context, requestID string, data []byte, fileName string) error
- type HeartbeatRequest
- type HeartbeatResponse
- type JobReportRequest
- type JobStats
- type LogBatch
- type Meta
- type PITRBaseBackupResult
- type PITRRestoreResult
- type PITRSetupResult
- type PITRStatusReport
- type PendingBackup
- type PendingFileDump
- type PendingRestore
- type ProgressReport
- type RegisterAgentRequest
- type RegisterAgentResponse
- type RegisterWithTokenResponse
- type RepoConfig
- type StorageBackendConfig
- type SystemMetadata
- type VersionInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClearPendingReports ¶
func ClearPendingReports()
ClearPendingReports removes the pending reports file.
func SavePendingReport ¶
func SavePendingReport(report JobReportRequest)
SavePendingReport persists a failed job report for later retry.
Types ¶
type ApiResponse ¶
ApiResponse is the standard NerdBackup API envelope.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) Deregister ¶ added in v0.2.3
Deregister deletes this agent from the NerdBackup API.
func (*Client) FlushPendingReports ¶
FlushPendingReports retries any saved pending reports.
func (*Client) GetLatestVersion ¶
func (c *Client) GetLatestVersion(ctx context.Context) (*VersionInfo, error)
GetLatestVersion checks for agent updates.
func (*Client) GetPendingBackups ¶ added in v0.2.5
func (c *Client) GetPendingBackups(ctx context.Context) ([]PendingBackup, error)
GetPendingBackups fetches any backup triggers queued from the dashboard.
func (*Client) GetPendingFileDumps ¶ added in v0.3.0
func (c *Client) GetPendingFileDumps(ctx context.Context) ([]PendingFileDump, error)
GetPendingFileDumps fetches any file download requests from the dashboard.
func (*Client) GetPendingRestores ¶ added in v0.2.4
func (c *Client) GetPendingRestores(ctx context.Context) ([]PendingRestore, error)
GetPendingRestores fetches any restore requests queued from the dashboard.
func (*Client) GetRepos ¶
GetRepos fetches repo configs with ETag support. Returns (repos, changed, error). If changed=false, repos is nil (304).
func (*Client) PostDockerVolumes ¶
PostDockerVolumes uploads discovered Docker volumes to the API.
func (*Client) ReportJob ¶
func (c *Client) ReportJob(ctx context.Context, req JobReportRequest) error
ReportJob reports a completed/failed job. Retries 5x, then saves to pending.
func (*Client) ReportProgress ¶
func (c *Client) ReportProgress(ctx context.Context, progress ProgressReport)
ReportProgress sends real-time backup progress. Best-effort, 1 retry.
func (*Client) SendHeartbeat ¶
func (c *Client) SendHeartbeat(ctx context.Context, req HeartbeatRequest) (*HeartbeatResponse, error)
SendHeartbeat sends a heartbeat. Returns config_changed flag.
type HeartbeatRequest ¶
type HeartbeatRequest struct {
AgentVersion string `json:"agent_version"`
ResticVersion string `json:"restic_version"`
Platform string `json:"platform"`
Arch string `json:"arch"`
Hostname string `json:"hostname"`
UptimeSeconds int64 `json:"uptime_seconds"`
LastBackupAt string `json:"last_backup_at,omitempty"`
DiskFreeBytes int64 `json:"disk_free_bytes"`
CPUCount int `json:"cpu_count"`
MemTotalBytes int64 `json:"memory_total_bytes"`
}
Heartbeat
type HeartbeatResponse ¶
type JobReportRequest ¶
type JobReportRequest struct {
RepoID string `json:"repo_id"`
PolicyID string `json:"policy_id,omitempty"`
DashboardJobID string `json:"dashboard_job_id,omitempty"`
Operation string `json:"operation"`
Status string `json:"status"`
StartedAt time.Time `json:"started_at"`
CompletedAt time.Time `json:"completed_at"`
ResticSnapshotID string `json:"restic_snapshot_id,omitempty"`
Stats JobStats `json:"stats"`
Files []map[string]interface{} `json:"files,omitempty"`
ErrorMessage string `json:"error_message,omitempty"`
}
Job report
func LoadPendingReports ¶
func LoadPendingReports() []JobReportRequest
LoadPendingReports reads all pending reports from disk.
type JobStats ¶
type JobStats struct {
FilesNew int `json:"files_new"`
FilesChanged int `json:"files_changed"`
FilesUnmodified int `json:"files_unmodified"`
DirsNew int `json:"dirs_new"`
DataAddedBytes int64 `json:"data_added_bytes"`
TotalFilesProcessed int `json:"total_files_processed"`
TotalBytesProcessed int64 `json:"total_bytes_processed"`
TotalDurationSec int `json:"total_duration_seconds"`
}
type PITRBaseBackupResult ¶ added in v0.10.0
type PITRBaseBackupResult struct {
ConfigID string `json:"config_id"`
BackupDir string `json:"backup_dir"`
ResticSnapshotID string `json:"restic_snapshot_id,omitempty"`
Status string `json:"status"` // "completed" or "failed"
StartedAt string `json:"started_at"`
CompletedAt string `json:"completed_at"`
Error string `json:"error,omitempty"`
}
PITRBaseBackupResult is the response after pitr_base_backup completes.
type PITRRestoreResult ¶ added in v0.10.0
type PITRRestoreResult struct {
ConfigID string `json:"config_id"`
TargetTime string `json:"target_time"`
RestoreDir string `json:"restore_dir"`
Status string `json:"status"` // "completed" or "failed"
StartedAt string `json:"started_at"`
CompletedAt string `json:"completed_at"`
Error string `json:"error,omitempty"`
}
PITRRestoreResult is the response after pitr_restore completes.
type PITRSetupResult ¶ added in v0.10.0
type PITRSetupResult struct {
ConfigID string `json:"config_id"`
ConfigLines string `json:"config_lines"`
ArchiveDir string `json:"archive_dir"`
Status string `json:"status"` // "success" or "failed"
Error string `json:"error,omitempty"`
}
PITRSetupResult is the response after pitr_setup completes.
type PITRStatusReport ¶ added in v0.10.0
type PITRStatusReport struct {
ConfigID string `json:"config_id"`
DatabaseType string `json:"database_type"`
DatabaseName string `json:"database_name"`
ConnectionHost string `json:"connection_host"`
WALCount int `json:"wal_count"`
WALSizeBytes int64 `json:"wal_size_bytes"`
CurrentRPOSec int `json:"current_rpo_seconds"`
LastWALArchived string `json:"last_wal_archived_at,omitempty"`
LastBaseBackup string `json:"last_base_backup_at,omitempty"`
ArchiveDir string `json:"archive_dir"`
Status string `json:"status"` // "active", "error", "not_configured"
ErrorMessage string `json:"error_message,omitempty"`
}
PITRStatusReport is sent to the server when pitr_status is requested.
type PendingBackup ¶ added in v0.2.5
type PendingBackup struct {
JobID string `json:"jobId"`
RepoID string `json:"repoId"`
CreatedAt string `json:"createdAt"`
}
Pending backup trigger from dashboard
type PendingFileDump ¶ added in v0.3.0
type PendingFileDump struct {
RequestID string `json:"requestId"`
SnapshotID string `json:"snapshotId"`
FilePath string `json:"filePath"`
CreatedAt string `json:"createdAt"`
}
Pending file dump request from dashboard (single file download)
type PendingRestore ¶ added in v0.2.4
type PendingRestore struct {
JobID string `json:"jobId"`
SnapshotID string `json:"snapshotId"`
TargetPath string `json:"targetPath"`
IncludePaths []string `json:"includePaths"`
ExcludePaths []string `json:"excludePaths"`
CreatedAt string `json:"createdAt"`
}
Pending restore request from dashboard
type ProgressReport ¶
type ProgressReport struct {
RepoID string `json:"repo_id"`
PercentDone float64 `json:"percent_done"`
BytesProcessed int64 `json:"bytes_processed"`
FilesProcessed int `json:"files_processed"`
CurrentFile string `json:"current_file,omitempty"`
StartedAt string `json:"started_at"`
}
Progress report (sent during backup)
type RegisterAgentRequest ¶
type RegisterAgentRequest struct {
Name string `json:"name"`
Platform string `json:"platform"`
Arch string `json:"arch"`
Hostname string `json:"hostname"`
}
Agent registration
type RegisterAgentResponse ¶
func Register ¶
func Register(baseURL, apiKey string, req RegisterAgentRequest) (*RegisterAgentResponse, error)
Register registers a new agent. Uses API key auth (not agent token).
type RegisterWithTokenResponse ¶ added in v0.1.2
type RegisterWithTokenResponse struct {
AgentID string `json:"agent_id"`
AgentToken string `json:"agent_token"`
APIBaseURL string `json:"api_base_url"`
}
func RegisterWithToken ¶ added in v0.1.2
func RegisterWithToken(baseURL, installToken string, req RegisterAgentRequest) (*RegisterWithTokenResponse, error)
RegisterWithToken registers an agent using a pre-authenticated install token.
type RepoConfig ¶
type RepoConfig struct {
ID string `json:"id"`
StorageBackendID string `json:"storage_backend_id"`
PolicyID string `json:"policy_id,omitempty"`
ResticRepoPath string `json:"restic_repo_path"`
ResticPassword string `json:"restic_password"`
Paths []string `json:"paths"`
ExcludePatterns []string `json:"exclude_patterns"`
ExcludePresets []string `json:"exclude_presets"`
Tags []string `json:"tags"`
ScheduleCron string `json:"schedule_cron,omitempty"`
BandwidthLimitKiB int `json:"bandwidth_limit_kib,omitempty"`
PreBackupCommand string `json:"pre_backup_command,omitempty"`
PostBackupCommand string `json:"post_backup_command,omitempty"`
CheckEveryNBackups int `json:"check_every_n_backups"`
Preset string `json:"preset,omitempty"` // "full-system", "docker-stop", "docker-hot"
StorageConfig StorageBackendConfig `json:"storage_config"`
ConfigHash string `json:"config_hash,omitempty"`
}
Repo config (returned by GET /agents/:id/repos — password decrypted server-side)
type StorageBackendConfig ¶
type SystemMetadata ¶
type SystemMetadata struct {
BootMode string `json:"boot_mode"` // "UEFI" or "BIOS"
Hostname string `json:"hostname"`
Kernel string `json:"kernel"`
Packages []string `json:"packages,omitempty"` // installed package names
EnabledServices []string `json:"enabled_services,omitempty"`
DiskUsage string `json:"disk_usage,omitempty"`
}
SystemMetadata is captured by the full-system preset pre-hook.
type VersionInfo ¶
type VersionInfo struct {
Version string `json:"version"`
Platforms map[string]string `json:"platforms"`
}
Version info