Documentation
¶
Overview ¶
Package backup makes encrypted backups of the controller (§13) and ships them to S3. A bundle holds a consistent SQLite snapshot (VACUUM INTO) and the key material in the data directory (CA, registry token key, …), sealed with the master key. The header carries the master key wrapped by the recovery key, so restoring needs the bundle plus the recovery key only.
Index ¶
- Constants
- Variables
- func Create(ctx context.Context, st *store.Store, box *secrets.Box, dataDir string, ...) error
- func Download(ctx context.Context, cfg Config, name string) ([]byte, string, error)
- func Rekey(bundle []byte, box *secrets.Box) ([]byte, error)
- func Restore(bundle []byte, recoveryKey, dataDir string, force bool) ([]string, error)
- type Config
- type Creds
- type Manager
- func (m *Manager) Config() (Config, bool)
- func (m *Manager) Disable(ctx context.Context) error
- func (m *Manager) EndpointInUse(_ context.Context, id string) string
- func (m *Manager) List(ctx context.Context) ([]Object, error)
- func (m *Manager) Load(ctx context.Context) error
- func (m *Manager) RekeyAll(ctx context.Context) (RekeyResult, error)
- func (m *Manager) Run(ctx context.Context)
- func (m *Manager) RunNow(ctx context.Context) (Object, error)
- func (m *Manager) SetConfig(ctx context.Context, c Config) error
- func (m *Manager) Status() Status
- func (m *Manager) WriteBundle(ctx context.Context, w io.Writer) error
- type Object
- type RekeyResult
- type Status
Constants ¶
const (
// Ext is the bundle file extension.
Ext = ".synbak"
)
const (
// TopicUpdated carries Status after every backup run.
TopicUpdated = "backup.updated"
)
Variables ¶
var ErrCurrent = errors.New("the backup already opens with the current recovery key")
ErrCurrent means a bundle already carries the current wrapped master key.
var ErrNotConfigured = errors.New("backups are not configured")
ErrNotConfigured is returned when no S3 destination is set.
var ErrOtherMasterKey = errors.New("the backup was made with another master key")
ErrOtherMasterKey means a bundle was sealed with another master key (another install, or one from before a restore onto a new key).
Functions ¶
func Create ¶
func Create(ctx context.Context, st *store.Store, box *secrets.Box, dataDir string, w io.Writer) error
Create writes an encrypted bundle of dataDir to w.
func Rekey ¶ added in v0.2.0
Rekey gives a bundle the box's current wrapped master key, so it opens with the current recovery key (Phase 19b). The body is checked to be sealed with the box's master key and is kept byte for byte. A bundle that already has the current key returns ErrCurrent and needs no upload.
Types ¶
type Config ¶
type Config struct {
// EndpointID is a registered S3 connection (ID; name accepted on input).
EndpointID string `json:"endpointId,omitempty"`
// EndpointName is the connection's name (shown, not stored).
EndpointName string `json:"endpointName,omitempty"`
Endpoint string `json:"endpoint"` // e.g. https://s3.eu-central-1.amazonaws.com, http://10.0.0.5:9000
Region string `json:"region"`
PathStyle bool `json:"pathStyle,omitempty"`
Bucket string `json:"bucket"`
Prefix string `json:"prefix"`
AccessKeyID string `json:"accessKeyId"`
SecretAccessKey string `json:"secretAccessKey,omitempty"`
IntervalMinutes int `json:"intervalMinutes"`
Retain int `json:"retain"`
}
Config is where and how often backups go. With EndpointID the credentials are a registered S3 connection's, read live at every run, so rotating its key there applies here too; otherwise they are the ones entered with the settings, and the secret is stored sealed.
type Manager ¶
type Manager struct {
// Connection resolves a registered S3 connection (by ID or name); nil
// means only entered credentials can be used.
Connection func(ctx context.Context, ref string) (Creds, error)
// Connections lists the registered S3 connections, so backups set up
// with entered keys can move to the matching one (adopt).
Connections func(ctx context.Context) ([]Creds, error)
// contains filtered or unexported fields
}
func NewManager ¶
func (*Manager) Config ¶
Config returns the configuration without the secret; with a connection, its current address and key ID.
func (*Manager) EndpointInUse ¶ added in v0.5.3
EndpointInUse blocks deleting the S3 connection backups go to.
func (*Manager) RekeyAll ¶ added in v0.2.0
func (m *Manager) RekeyAll(ctx context.Context) (RekeyResult, error)
RekeyAll re-keys every stored backup in place so it opens with the current recovery key (Phase 19b). Backups are not run meanwhile.
type RekeyResult ¶ added in v0.2.0
type RekeyResult struct {
Rekeyed int `json:"rekeyed"`
// Current already opened with the current recovery key.
Current int `json:"current"`
// Skipped were made with another master key and left as they are.
Skipped []string `json:"skipped"`
// Failed could not be read or written (name: error).
Failed []string `json:"failed"`
}
RekeyResult is the outcome of re-keying the stored backups.