Documentation
¶
Index ¶
- func DeleteBackup(archivePath string) error
- func PruneBackups(backupDir string, maxKeep int) (deleted int, err error)
- func Restore(archivePath string, opts BackupOptions) error
- func RestoreSQLBackup(ctx context.Context, archivePath string, opts SQLBackupOptions) error
- type BackupInfo
- type BackupOptions
- type SQLBackupOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeleteBackup ¶
DeleteBackup removes a backup archive.
func PruneBackups ¶ added in v0.8.2
PruneBackups keeps only the most recent maxKeep backups, deleting older ones.
func Restore ¶
func Restore(archivePath string, opts BackupOptions) error
Restore extracts a backup archive, replacing existing data.
func RestoreSQLBackup ¶ added in v0.12.3
func RestoreSQLBackup(ctx context.Context, archivePath string, opts SQLBackupOptions) error
RestoreSQLBackup restores a SQL-based backup by reading JSONL and inserting rows. Tables are truncated before insertion to ensure idempotent restores.
Types ¶
type BackupInfo ¶
type BackupInfo struct {
Filename string `json:"filename"`
Path string `json:"path"`
Version string `json:"version"`
CreatedAt time.Time `json:"created_at"`
Size int64 `json:"size"`
}
BackupInfo describes a backup archive.
func Create ¶
func Create(opts BackupOptions, version string) (*BackupInfo, error)
Create creates a tar.gz backup archive with ClickHouse data, SQLite, and config.
func CreateSQLBackup ¶ added in v0.12.3
func CreateSQLBackup(ctx context.Context, opts SQLBackupOptions, version string) (*BackupInfo, error)
CreateSQLBackup performs a live backup by querying each table via the ClickHouse HTTP interface using FORMAT JSONEachRow. Each table is streamed to a temp file first to avoid loading the entire dataset in memory. No ClickHouse restart is required.
func ListBackups ¶
func ListBackups(backupDir string) ([]BackupInfo, error)
ListBackups returns backups sorted newest first.
type BackupOptions ¶
type BackupOptions struct {
DataDir string // ClickHouse data directory
SQLitePath string // Path to crawlobserver.db
ConfigPath string // Path to config.yaml
BackupDir string // Where to store backups
}
BackupOptions configures what to include in a backup.
type SQLBackupOptions ¶ added in v0.12.3
type SQLBackupOptions struct {
CHURL string // ClickHouse HTTP URL, e.g. "http://localhost:18123"
Database string // database name
Username string
Password string
SQLitePath string // crawlobserver.db
ConfigPath string // config.yaml
BackupDir string // where to write backup archives
}
SQLBackupOptions configures a live SQL-based backup (no ClickHouse restart needed).