Documentation
¶
Overview ¶
Package backup creates and restores tar.gz snapshots of the data directory (SQLite DB, certs, generated config, ACME account). The master state needed to reproduce a working panel lives entirely under the data dir.
Index ¶
- Constants
- func ApplyPending(dataDir string) (applied bool, err error)
- func Create(dataDir, out string) error
- func ListLocal(dataDir string) ([]string, error)
- func Restore(file, dataDir string) error
- func Rotate(dataDir string, keep int) (removed int, err error)
- func StageRestore(file, dataDir string) error
- func WriteLocal(dataDir string, m Manifest, checkpoint func() error, now time.Time) (string, error)
- func WriteWithManifest(dataDir string, m Manifest, w io.Writer) error
- type Manifest
Constants ¶
const LocalBackupDir = "backups"
LocalBackupDir is the subdirectory of the data dir holding scheduled local archives. WriteWithManifest skips it, so archives never nest inside each other.
Variables ¶
This section is empty.
Functions ¶
func ApplyPending ¶
ApplyPending applies a staged restore (if any) over dataDir, then clears the staging area. Call it on boot before opening the database. No-op when nothing is staged. Re-downloadable assets not present in the backup (bin/, geo/) are left in place.
func Rotate ¶ added in v0.13.0
Rotate deletes the oldest local archives, keeping the newest keep. keep <= 0 disables rotation (retain everything) rather than deleting the lot — a zero value from an unset config must never be read as "erase every backup I have".
func StageRestore ¶
StageRestore unpacks a backup into a staging area inside dataDir and marks it ready. The restore is applied by ApplyPending on the next boot, BEFORE the database is opened — so a live SQLite WAL can't checkpoint stale data back over the restored DB (which would silently revert the restore). On failure the live data is left untouched.
func WriteLocal ¶ added in v0.13.0
WriteLocal builds a backup archive into <dataDir>/backups and returns its path. checkpoint (may be nil) flushes the DB's WAL first so the archived DB is complete.
The archive is written to a temp name in the same directory and renamed into place, so a crash mid-write can't leave a truncated file that looks like a valid backup — and so Rotate never sees a half-written archive as a rotation candidate.
Types ¶
type Manifest ¶
type Manifest struct {
Domain string `json:"domain"`
SecretPath string `json:"secret_path"`
UserCount int `json:"user_count"`
CreatedAt string `json:"created_at"`
}
Manifest is written as manifest.json (the first tar entry) in every backup. It lets the operator preview what a backup contains before restoring.