Documentation
¶
Overview ¶
Package backup writes database dumps, docker volumes, and the panel's own SQLite file to S3-compatible destinations, restores from them, prunes old archives, and runs the schedules that trigger all of it.
Every archive is spooled to a local scratch file before it is uploaded. That is what makes the volume modes work: the container is only frozen for the length of the local tar, never for the length of the upload. It also gives restore something to verify before it wipes anything.
Index ¶
- func OrgOf(ctx context.Context, store repo.Store, t *repo.Tile) (string, error)
- func ParseRef(s string) (scope, name string, ok bool)
- func ResolveDestination(ctx context.Context, store repo.Store, orgID, destID string) (*repo.BackupDestination, error)
- func ResolveNamed(ctx context.Context, store repo.Store, orgID, scope, name string) (*repo.BackupDestination, error)
- func TestDestination(ctx context.Context, d *repo.BackupDestination) error
- func ValidMode(m string) bool
- func Validate(b *repo.Backup) error
- func VolumeFor(t *repo.Tile) (string, error)
- type Service
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseRef ¶
ParseRef reads a destination reference, ${{ org.backups.NAME }} or ${{ stackr.backups.NAME }}, into its scope and name. ok is false for anything that is not a reference, which the caller then treats as a destination id.
func ResolveDestination ¶
func ResolveDestination(ctx context.Context, store repo.Store, orgID, destID string) (*repo.BackupDestination, error)
ResolveDestination loads a destination and refuses it unless the caller's org may use it: its own, or an admin-global one the admin has marked shared.
This is the check a route-level "tile → org → membership" pass does not make. The tile genuinely belongs to the caller's org; the destination is what crosses the tenant boundary, and it carries the credentials the archive is written with. Both the web handlers and the v1 API go through here.
func ResolveNamed ¶
func ResolveNamed(ctx context.Context, store repo.Store, orgID, scope, name string) (*repo.BackupDestination, error)
ResolveNamed finds the destination a config file's `dest:` reference points at. scope is "org" for ${{ org.backups.NAME }} and "stackr" for ${{ stackr.backups.NAME }}.
Names, not ids: the file is in git and shared across environments, and a destination id means nothing to a person reading it. Two destinations with the same name in reach is an error rather than a coin flip.
func TestDestination ¶
func TestDestination(ctx context.Context, d *repo.BackupDestination) error
TestDestination verifies a destination by writing and deleting a probe.
Types ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func (*Service) LoadSchedules ¶
LoadSchedules (re)registers cron entries for every enabled backup. Call it at startup and after any change to a schedule.
func (*Service) Restore ¶
Restore puts one recorded run back. The run is loaded by id and must belong to this backup, the object key is never taken from the caller, because on a shared bucket that would be a cross-tenant read.
Volume restores are destructive and ordered so that every recoverable failure happens before the wipe: take a pre-restore backup, download, verify, and only then stop → wipe → extract → start.