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 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 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
- type CollectorConfig
- type CollectorDeps
- type CompressionError
- type FileSummary
- type Manifest
- 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 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 temporaneamente sostituisce lookPath (per i test) e restituisce una funzione di ripristino da invocare con 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
}
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 CollectionStats ¶
type CollectionStats struct {
FilesProcessed int64
FilesFailed 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.
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
// PBS-specific collection options
BackupDatastoreConfigs bool
BackupUserConfigs bool
BackupRemoteConfigs bool
BackupSyncJobs bool
BackupVerificationJobs bool
BackupTapeConfigs 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
PxarIntraConcurrency int
PxarScanFanoutLevel int
PxarScanMaxRoots int
PxarStopOnCap bool
PxarEnumWorkers int
PxarEnumBudgetMs 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 rappresenta un errore di compressione esterna (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 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.