Documentation
¶
Index ¶
- func DecryptBackup(encrypted []byte, password string) ([]byte, error)
- func DecryptFile(inputPath, outputPath, password string) error
- func EncryptBackup(data []byte, password string) ([]byte, error)
- func EncryptFile(inputPath, outputPath, password string) error
- func HashPassword(password string) string
- func IsEncrypted(backupPath string) bool
- func VerifyPassword(password, hash string) bool
- type BackupInfo
- type BackupMetadata
- type Manager
- func (m *Manager) ApplyRetention(policy RetentionPolicy) error
- func (m *Manager) Create(filename string) (string, error)
- func (m *Manager) CreateAndVerify(filename string) (string, *VerificationResult, error)
- func (m *Manager) CreateEncrypted(filename string) (string, error)
- func (m *Manager) CreateEncryptedAndVerify(filename string) (string, *VerificationResult, error)
- func (m *Manager) Delete(filename string) error
- func (m *Manager) GetMetadata(backupPath string) (*BackupMetadata, error)
- func (m *Manager) List() ([]BackupInfo, error)
- func (m *Manager) Restore(backupPath string) error
- func (m *Manager) RestoreEncrypted(backupPath string) error
- func (m *Manager) ScheduledBackup(keepCount int) error
- func (m *Manager) ScheduledBackupWithVerification(keepCount int) error
- func (m *Manager) SetCreatedBy(username string)
- func (m *Manager) SetPassword(password string)
- func (m *Manager) VerifyBackup(backupPath string) (*VerificationResult, error)
- type RetentionPolicy
- type VerificationResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecryptBackup ¶
DecryptBackup decrypts backup data using AES-256-GCM Per AI.md PART 24: Backup Encryption
func DecryptFile ¶
DecryptFile decrypts a file and writes to output path
func EncryptBackup ¶
EncryptBackup encrypts backup data using AES-256-GCM with password-based key derivation Per AI.md PART 24: Backup Encryption (NON-NEGOTIABLE) Algorithm: AES-256-GCM Key Derivation: Argon2id (password → encryption key) Password Storage: NEVER stored - admin must remember
func EncryptFile ¶
EncryptFile encrypts a file and writes to output path
func HashPassword ¶
HashPassword creates a SHA-256 hash of the password for verification This is NOT stored - only used to verify password hasn't changed
func IsEncrypted ¶
IsEncrypted checks if a backup file is encrypted (has .enc extension) Per AI.md PART 22: .enc extension for encrypted backups
func VerifyPassword ¶
VerifyPassword checks if a password matches the stored hash
Types ¶
type BackupInfo ¶
type BackupInfo struct {
Filename string `json:"filename"`
Path string `json:"path"`
Size int64 `json:"size"`
CreatedAt time.Time `json:"created_at"`
Version string `json:"version,omitempty"`
ServerTitle string `json:"server_title,omitempty"`
FileCount int `json:"file_count,omitempty"`
}
BackupInfo contains summary information about a backup
func (BackupInfo) FormatSize ¶
func (bi BackupInfo) FormatSize() string
FormatSize returns a human-readable size
type BackupMetadata ¶
type BackupMetadata struct {
Version string `json:"version"` // Manifest format version (e.g., "1.0.0")
CreatedAt time.Time `json:"created_at"` // When backup was created
CreatedBy string `json:"created_by"` // Who created the backup (per PART 25)
AppVersion string `json:"app_version"` // Application version (per PART 25)
Contents []string `json:"contents"` // List of files/directories in backup
Checksums map[string]string `json:"checksums"` // SHA256 checksums per file
Checksum string `json:"checksum"` // Overall archive checksum (per PART 25)
Encrypted bool `json:"encrypted"` // Per AI.md PART 25
EncryptionMethod string `json:"encryption_method"` // "AES-256-GCM" if encrypted
// Legacy fields for backwards compatibility
ServerTitle string `json:"server_title,omitempty"` // Server title (optional)
Size int64 `json:"size,omitempty"` // Total size in bytes (optional)
Files []string `json:"files,omitempty"` // Deprecated: use Contents
}
BackupMetadata contains information about a backup Per AI.md PART 25: manifest.json format with required fields
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager handles backup and restore operations
func (*Manager) ApplyRetention ¶
func (m *Manager) ApplyRetention(policy RetentionPolicy) error
ApplyRetention applies retention policy to backups Per AI.md PART 22: Smart retention with daily/weekly/monthly/yearly buckets
func (*Manager) CreateAndVerify ¶
func (m *Manager) CreateAndVerify(filename string) (string, *VerificationResult, error)
CreateAndVerify creates a backup and verifies it immediately Per AI.md PART 22: Only delete old backups if new backup passes ALL verification checks
func (*Manager) CreateEncrypted ¶
CreateEncrypted creates an encrypted backup with .enc extension Per AI.md PART 22: .enc extension for encrypted backups
func (*Manager) CreateEncryptedAndVerify ¶
func (m *Manager) CreateEncryptedAndVerify(filename string) (string, *VerificationResult, error)
CreateEncryptedAndVerify creates an encrypted backup and verifies it Per AI.md PART 22: All encrypted backups must pass decrypt test
func (*Manager) GetMetadata ¶
func (m *Manager) GetMetadata(backupPath string) (*BackupMetadata, error)
GetMetadata reads metadata from a backup archive Looks for manifest.json (per AI.md PART 26) or legacy backup.json
func (*Manager) List ¶
func (m *Manager) List() ([]BackupInfo, error)
List returns all available backups
func (*Manager) RestoreEncrypted ¶
RestoreEncrypted restores from an encrypted backup (.enc extension) Per AI.md PART 22: .enc extension for encrypted backups
func (*Manager) ScheduledBackup ¶
ScheduledBackup performs a scheduled backup with cleanup of old backups
func (*Manager) ScheduledBackupWithVerification ¶
ScheduledBackupWithVerification performs a scheduled backup with verification Per AI.md PART 22: Only delete old backups if new backup passes ALL verification checks
func (*Manager) SetCreatedBy ¶
SetCreatedBy sets the username for backup attribution (per AI.md PART 25)
func (*Manager) SetPassword ¶
SetPassword sets the backup encryption password Per AI.md PART 24: Password is NEVER stored - derived on-demand
func (*Manager) VerifyBackup ¶
func (m *Manager) VerifyBackup(backupPath string) (*VerificationResult, error)
VerifyBackup verifies backup integrity immediately after creation Per AI.md PART 22 (NON-NEGOTIABLE): - File exists - Size > 0 - Checksum valid - Manifest readable - Decrypt test (if encrypted)
type RetentionPolicy ¶
type RetentionPolicy struct {
Count int `json:"count" yaml:"count"` // Number of backups to keep
Day int `json:"day" yaml:"day"` // Days to keep daily backups
Week int `json:"week" yaml:"week"` // Weeks to keep weekly backups
Month int `json:"month" yaml:"month"` // Months to keep monthly backups
Year int `json:"year" yaml:"year"` // Years to keep yearly backups
}
RetentionPolicy defines backup retention rules per AI.md PART 22 Per AI.md PART 22: Retention policies (count, day, week, month, year)
func DefaultRetentionPolicy ¶
func DefaultRetentionPolicy() RetentionPolicy
DefaultRetentionPolicy returns the default retention policy Per AI.md PART 22: Reasonable defaults
type VerificationResult ¶
type VerificationResult struct {
FileExists bool `json:"file_exists"`
SizeValid bool `json:"size_valid"`
ChecksumValid bool `json:"checksum_valid"`
ManifestValid bool `json:"manifest_valid"`
DecryptValid bool `json:"decrypt_valid"` // Only for encrypted backups
AllPassed bool `json:"all_passed"`
Errors []string `json:"errors,omitempty"`
}
VerificationResult contains the results of backup verification Per AI.md PART 22: Backup verification is NON-NEGOTIABLE