Documentation
¶
Index ¶
- func ApplyOptimizations(ctx context.Context, logger *logging.Logger, root string, ...) error
- func CreateManifest(ctx context.Context, logger *logging.Logger, manifest *Manifest, ...) error
- func FindExcludeMatch(patterns []string, path, tempDir, systemRootPrefix string) (bool, string)
- func FormatBytes(bytes int64) string
- func FormatDuration(d time.Duration) string
- func GenerateChecksum(ctx context.Context, logger *logging.Logger, filePath string) (string, error)
- func VerifyChecksum(ctx context.Context, logger *logging.Logger, filePath, expectedChecksum string) (bool, error)
- func WithLookPathOverride(fn func(string) (string, error)) func()
- type Archiver
- func (a *Archiver) CompressionLevel() int
- func (a *Archiver) CompressionMode() string
- func (a *Archiver) CompressionThreads() int
- func (a *Archiver) CreateArchive(ctx context.Context, sourceDir, outputPath string) error
- func (a *Archiver) EffectiveCompression() types.CompressionType
- func (a *Archiver) EstimateCompressionRatio() float64
- func (a *Archiver) GetArchiveExtension() string
- func (a *Archiver) GetArchiveSize(archivePath string) (int64, error)
- func (a *Archiver) RequestedCompression() types.CompressionType
- func (a *Archiver) ResolveCompression() types.CompressionType
- func (a *Archiver) VerifyArchive(ctx context.Context, archivePath string) error
- type ArchiverConfig
- type ArchiverDeps
- type BackupManifest
- type CollectionStats
- type Collector
- func (c *Collector) CollectAll(ctx context.Context) error
- func (c *Collector) CollectPBSConfigs(ctx context.Context) error
- func (c *Collector) CollectPVEConfigs(ctx context.Context) error
- func (c *Collector) CollectSystemInfo(ctx context.Context) error
- func (c *Collector) GetStats() *CollectionStats
- func (c *Collector) IsClusteredPVE() bool
- func (c *Collector) WriteManifest(hostname string) error
- type CollectorConfig
- type CollectorDeps
- type CompressionError
- type FileSummary
- type Manifest
- type ManifestEntry
- type ManifestFileStatus
- type ManifestStats
- type OptimizationConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyOptimizations ¶
func ApplyOptimizations(ctx context.Context, logger *logging.Logger, root string, cfg OptimizationConfig) error
ApplyOptimizations executes the requested optimizations in sequence.
func CreateManifest ¶
func CreateManifest(ctx context.Context, logger *logging.Logger, manifest *Manifest, outputPath string) error
CreateManifest creates a manifest file with archive metadata and checksum
func FindExcludeMatch ¶ added in v0.13.0
func FormatBytes ¶
FormatBytes formats bytes in human-readable format
func FormatDuration ¶
FormatDuration formats a duration in human-readable format
func GenerateChecksum ¶
GenerateChecksum calculates SHA256 checksum of a file
func VerifyChecksum ¶
func VerifyChecksum(ctx context.Context, logger *logging.Logger, filePath, expectedChecksum string) (bool, error)
VerifyChecksum verifies a file against a manifest's checksum
func WithLookPathOverride ¶
WithLookPathOverride temporarily replaces lookPath (for tests) and returns a restore function to call with defer.
Types ¶
type Archiver ¶
type Archiver struct {
// contains filtered or unexported fields
}
Archiver handles tar archive creation with compression
func NewArchiver ¶
func NewArchiver(logger *logging.Logger, config *ArchiverConfig) *Archiver
NewArchiver creates a new archiver
func (*Archiver) CompressionLevel ¶
CompressionLevel returns the current compression level (already normalized).
func (*Archiver) CompressionMode ¶
CompressionMode returns the active compression mode (fast/standard/maximum/ultra).
func (*Archiver) CompressionThreads ¶
CompressionThreads returns the number of threads requested for compression.
func (*Archiver) CreateArchive ¶
CreateArchive creates a compressed tar archive from a directory
func (*Archiver) EffectiveCompression ¶
func (a *Archiver) EffectiveCompression() types.CompressionType
EffectiveCompression returns the compression algorithm currently in use.
func (*Archiver) EstimateCompressionRatio ¶
EstimateCompressionRatio returns an estimated compression ratio for the compression type
func (*Archiver) GetArchiveExtension ¶
GetArchiveExtension returns the appropriate file extension for the compression type
func (*Archiver) GetArchiveSize ¶
GetArchiveSize returns the size of the archive in bytes
func (*Archiver) RequestedCompression ¶
func (a *Archiver) RequestedCompression() types.CompressionType
RequestedCompression returns the compression algorithm requested via configuration.
func (*Archiver) ResolveCompression ¶
func (a *Archiver) ResolveCompression() types.CompressionType
ResolveCompression ensures the configured compression is available and normalizes the compression level. If the requested algorithm is unavailable it falls back to gzip, keeping the caller informed via logs.
type ArchiverConfig ¶
type ArchiverConfig struct {
Compression types.CompressionType
CompressionLevel int // 1-9 for gzip, 0-9 for xz, 1-22 for zstd
CompressionThreads int
CompressionMode string
DryRun bool
EncryptArchive bool
AgeRecipients []age.Recipient
ExcludePatterns []string
}
ArchiverConfig holds configuration for archive creation
func GetDefaultArchiverConfig ¶
func GetDefaultArchiverConfig() *ArchiverConfig
GetDefaultArchiverConfig returns default archiver configuration
func (*ArchiverConfig) Validate ¶
func (a *ArchiverConfig) Validate() error
Validate checks if the archiver configuration is valid
type ArchiverDeps ¶
type ArchiverDeps struct {
LookPath func(string) (string, error)
CommandContext func(context.Context, string, ...string) *exec.Cmd
}
ArchiverDeps groups external dependencies used by Archiver.
type BackupManifest ¶ added in v0.13.0
type BackupManifest struct {
CreatedAt time.Time `json:"created_at"`
Hostname string `json:"hostname"`
ProxmoxType string `json:"proxmox_type"`
PBSConfigs map[string]ManifestEntry `json:"pbs_configs,omitempty"`
PVEConfigs map[string]ManifestEntry `json:"pve_configs,omitempty"`
SystemFiles map[string]ManifestEntry `json:"system_files,omitempty"`
Stats ManifestStats `json:"stats"`
}
BackupManifest contains metadata about all files in the backup
type CollectionStats ¶
type CollectionStats struct {
FilesProcessed int64
FilesFailed int64
FilesNotFound int64
FilesSkipped int64
DirsCreated int64
BytesCollected int64
}
CollectionStats tracks statistics during backup collection
type Collector ¶
type Collector struct {
// contains filtered or unexported fields
}
Collector handles backup data collection
func NewCollector ¶
func NewCollector(logger *logging.Logger, config *CollectorConfig, tempDir string, proxType types.ProxmoxType, dryRun bool) *Collector
NewCollector creates a new backup collector
func NewCollectorWithDeps ¶
func NewCollectorWithDeps(logger *logging.Logger, config *CollectorConfig, tempDir string, proxType types.ProxmoxType, dryRun bool, deps CollectorDeps) *Collector
NewCollectorWithDeps creates a collector with explicit dependency overrides (for testing).
func (*Collector) CollectAll ¶
CollectAll performs full backup collection based on Proxmox type
func (*Collector) CollectPBSConfigs ¶
CollectPBSConfigs collects Proxmox Backup Server specific configurations
func (*Collector) CollectPVEConfigs ¶
CollectPVEConfigs collects Proxmox VE specific configurations
func (*Collector) CollectSystemInfo ¶
CollectSystemInfo collects common system information (both PVE and PBS)
func (*Collector) GetStats ¶
func (c *Collector) GetStats() *CollectionStats
GetStats returns current collection statistics
func (*Collector) IsClusteredPVE ¶
IsClusteredPVE returns true if the current PVE collection detected a cluster.
func (*Collector) WriteManifest ¶ added in v0.13.0
WriteManifest writes the backup manifest to the temp directory
type CollectorConfig ¶
type CollectorConfig struct {
// PVE-specific collection options
BackupVMConfigs bool
BackupClusterConfig bool
BackupPVEFirewall bool
BackupVZDumpConfig bool
BackupPVEACL bool
BackupPVEJobs bool
BackupPVESchedules bool
BackupPVEReplication bool
BackupPVEBackupFiles bool
BackupSmallPVEBackups bool
MaxPVEBackupSizeBytes int64
PVEBackupIncludePattern string
BackupCephConfig bool
CephConfigPath string
PveshTimeoutSeconds int
FsIoTimeoutSeconds int
// PBS-specific collection options
BackupDatastoreConfigs bool
BackupPBSS3Endpoints bool
BackupPBSNodeConfig bool
BackupPBSAcmeAccounts bool
BackupPBSAcmePlugins bool
BackupPBSMetricServers bool
BackupPBSTrafficControl bool
BackupPBSNotifications bool
BackupPBSNotificationsPriv bool
BackupUserConfigs bool
BackupRemoteConfigs bool
BackupSyncJobs bool
BackupVerificationJobs bool
BackupTapeConfigs bool
BackupPBSNetworkConfig bool
BackupPruneSchedules bool
BackupPxarFiles bool
// System collection options
BackupNetworkConfigs bool
BackupAptSources bool
BackupCronJobs bool
BackupSystemdServices bool
BackupSSLCerts bool
BackupSysctlConfig bool
BackupKernelModules bool
BackupFirewallRules bool
BackupInstalledPackages bool
BackupScriptDir bool
BackupCriticalFiles bool
BackupSSHKeys bool
BackupZFSConfig bool
BackupRootHome bool
BackupScriptRepository bool
BackupUserHomes bool
BackupConfigFile bool
SystemRootPrefix string
// PXAR scanning tuning
PxarDatastoreConcurrency int
PxarFileIncludePatterns []string
PxarFileExcludePatterns []string
// Exclude patterns (glob patterns to skip)
ExcludePatterns []string
CustomBackupPaths []string
BackupBlacklist []string
// Paths and overrides
ScriptRepositoryPath string
ConfigFilePath string
PVEConfigPath string
PVEClusterPath string
CorosyncConfigPath string
VzdumpConfigPath string
PBSConfigPath string
PBSDatastorePaths []string
// PBS Authentication (auto-detected)
PBSRepository string
PBSPassword string
PBSFingerprint string
}
CollectorConfig holds configuration for backup collection
func GetDefaultCollectorConfig ¶
func GetDefaultCollectorConfig() *CollectorConfig
GetDefaultCollectorConfig returns default collection configuration
func (*CollectorConfig) Validate ¶
func (c *CollectorConfig) Validate() error
Validate checks if the collector configuration is valid
type CollectorDeps ¶
type CollectorDeps struct {
LookPath func(string) (string, error)
RunCommandWithEnv func(context.Context, []string, string, ...string) ([]byte, error)
RunCommand func(context.Context, string, ...string) ([]byte, error)
Stat func(string) (os.FileInfo, error)
}
CollectorDeps allows injecting external dependencies for the Collector.
type CompressionError ¶
CompressionError represents an external compression error (xz/zstd).
func (*CompressionError) Error ¶
func (e *CompressionError) Error() string
func (*CompressionError) Unwrap ¶
func (e *CompressionError) Unwrap() error
type FileSummary ¶
type FileSummary struct {
RelativePath string `json:"relative_path"`
SizeBytes int64 `json:"size_bytes"`
SizeHuman string `json:"size_human"`
ModTime time.Time `json:"mod_time"`
}
FileSummary represents metadata about a sampled file
type Manifest ¶
type Manifest struct {
ArchivePath string `json:"archive_path"`
ArchiveSize int64 `json:"archive_size"`
SHA256 string `json:"sha256"`
CreatedAt time.Time `json:"created_at"`
CompressionType string `json:"compression_type"`
CompressionLevel int `json:"compression_level"`
CompressionMode string `json:"compression_mode,omitempty"`
ProxmoxType string `json:"proxmox_type"`
ProxmoxTargets []string `json:"proxmox_targets,omitempty"`
ProxmoxVersion string `json:"proxmox_version,omitempty"`
Hostname string `json:"hostname"`
ScriptVersion string `json:"script_version,omitempty"`
EncryptionMode string `json:"encryption_mode,omitempty"`
ClusterMode string `json:"cluster_mode,omitempty"`
}
Manifest represents backup archive metadata with checksums
func LoadManifest ¶
LoadManifest loads a manifest from a JSON file
type ManifestEntry ¶ added in v0.13.0
type ManifestEntry struct {
Status ManifestFileStatus `json:"status"`
Size int64 `json:"size,omitempty"`
Error string `json:"error,omitempty"`
}
ManifestEntry represents a single file entry in the manifest
type ManifestFileStatus ¶ added in v0.13.0
type ManifestFileStatus string
ManifestFileStatus represents the status of a file in the backup manifest
const ( StatusCollected ManifestFileStatus = "collected" StatusNotFound ManifestFileStatus = "not_found" StatusFailed ManifestFileStatus = "failed" StatusSkipped ManifestFileStatus = "skipped" StatusDisabled ManifestFileStatus = "disabled" )
type ManifestStats ¶ added in v0.13.0
type ManifestStats struct {
FilesProcessed int64 `json:"files_processed"`
FilesFailed int64 `json:"files_failed"`
FilesNotFound int64 `json:"files_not_found"`
FilesSkipped int64 `json:"files_skipped"`
DirsCreated int64 `json:"dirs_created"`
BytesCollected int64 `json:"bytes_collected"`
}
ManifestStats contains summary statistics for the manifest
type OptimizationConfig ¶
type OptimizationConfig struct {
EnableChunking bool
EnableDeduplication bool
EnablePrefilter bool
ChunkSizeBytes int64
ChunkThresholdBytes int64
PrefilterMaxFileSizeBytes int64
}
OptimizationConfig controls optional preprocessing steps executed before archiving.
func (OptimizationConfig) Enabled ¶
func (c OptimizationConfig) Enabled() bool
Enabled returns true if at least one optimization is active.
Source Files
¶
- archiver.go
- checksum.go
- collector.go
- collector_deps.go
- collector_manifest.go
- collector_network_inventory.go
- collector_paths.go
- collector_pbs.go
- collector_pbs_datastore.go
- collector_pbs_datastore_inventory.go
- collector_pbs_notifications_summary.go
- collector_pve.go
- collector_system.go
- fs_sampling_bounded.go
- optimizations.go