backup

package
v0.0.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 3, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package backup provides backup and restore functionality for XxSql.

Index

Constants

View Source
const (
	// BackupVersion is the current backup format version.
	BackupVersion = "1.0"

	// BackupExt is the extension for backup files.
	BackupExt = ".xbak"
)

Variables

This section is empty.

Functions

func ListBackups

func ListBackups(dir string) ([]string, error)

ListBackups lists all backup files in a directory.

Types

type BackupOptions

type BackupOptions struct {
	Path       string
	Compress   bool
	Database   string
	TableNames []string // empty means all tables
}

BackupOptions holds options for backup operations.

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager handles backup and restore operations.

func NewManager

func NewManager(dataDir string) *Manager

NewManager creates a new backup manager.

func (*Manager) Backup

func (m *Manager) Backup(opts BackupOptions) (*Manifest, error)

Backup creates a full backup of the database.

func (*Manager) Restore

func (m *Manager) Restore(opts RestoreOptions) (*Manifest, error)

Restore restores the database from a backup file.

func (*Manager) VerifyBackup

func (m *Manager) VerifyBackup(path string) (*Manifest, error)

VerifyBackup verifies the integrity of a backup file.

type Manifest

type Manifest struct {
	Version    string          `json:"version"`
	Timestamp  string          `json:"timestamp"`
	Database   string          `json:"database"`
	TableCount int             `json:"table_count"`
	Tables     []TableManifest `json:"tables"`
	Checksum   string          `json:"checksum"`
	Compressed bool            `json:"compressed"`
	TotalSize  int64           `json:"total_size"`
}

Manifest represents the backup manifest.

type RestoreOptions

type RestoreOptions struct {
	Path string
}

RestoreOptions holds options for restore operations.

type TableManifest

type TableManifest struct {
	Name      string `json:"name"`
	RowCount  uint64 `json:"row_count"`
	PageCount int    `json:"page_count"`
	Size      int64  `json:"size"`
}

TableManifest represents metadata for a single table in the backup.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL