Documentation
¶
Overview ¶
Package cloud keeps an encrypted copy of a backup in an S3-compatible bucket the owner controls (D70): AWS S3, Cloudflare R2, Backblaze B2, Wasabi, MinIO. The client is a small Signature V4 implementation on the standard library (path-style URLs, one PUT per object), so no SDK is pulled in.
Index ¶
- Variables
- func Configured(c store.CloudConfig) bool
- func Due(lastStarted string, lastStatus string, intervalHours int, now time.Time) bool
- func Fetch(ctx context.Context, cl *Client, object string, key []byte, dest string) (string, error)
- func KeyHint(hexKey string) string
- func NewRecoveryKey() (string, error)
- func ObjectPrefix(c store.CloudConfig) string
- func Open(r io.Reader, key []byte) (io.Reader, error)
- func Pack(w io.Writer, dir string) error
- func ParseRecoveryKey(s string) ([]byte, error)
- func Prune(ctx context.Context, cl *Client, prefix string, keep int) (int, error)
- func Seal(w io.Writer, key []byte) (io.WriteCloser, error)
- func Unpack(r io.Reader, dest string) (string, error)
- type Client
- type ErrStatus
- type Job
- type Object
- type Outcome
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotConfigured = errors.New("cloud: backup is not configured") ErrBusy = errors.New("cloud: a backup is already running") )
ErrNotConfigured means a setting the run needs is empty; ErrBusy means a run is already going.
var ErrOpen = errors.New("cloud: archive does not open with this key, or it is damaged")
ErrOpen means the archive does not open with this key or is damaged; no plaintext was trusted.
Functions ¶
func Configured ¶
func Configured(c store.CloudConfig) bool
Configured reports whether every value a run needs is present.
func Due ¶
Due reports whether a run should start now: none yet, the last one older than the interval, or the last one failed more than retryAfter ago.
func Fetch ¶
Fetch downloads object, opens it with key and unpacks it under dest; it returns the snapshot folder.
func NewRecoveryKey ¶
NewRecoveryKey returns a fresh key as 64 hex characters.
func ObjectPrefix ¶
func ObjectPrefix(c store.CloudConfig) string
ObjectPrefix is where this install's archives live in the bucket.
func Open ¶
Open returns a reader of the plaintext; it fails with ErrOpen on a wrong key, an edited chunk or a missing end. Every byte it returns has been authenticated.
func Pack ¶
Pack writes dir (a backup snapshot) as tar.gz into w: regular files and folders only, paths relative.
func ParseRecoveryKey ¶
ParseRecoveryKey accepts the key with or without spaces/dashes between groups.
func Prune ¶
Prune deletes the oldest archives under prefix beyond keep (keys carry a UTC timestamp, so they sort).
Types ¶
type Client ¶
type Client struct {
Endpoint string // https://<account>.r2.cloudflarestorage.com, https://s3.us-west-004.backblazeb2.com, …
Region string // "auto" for R2; the bucket's region elsewhere
Bucket string
AccessKey string
SecretKey string
HTTP *http.Client
// contains filtered or unexported fields
}
Client talks to one bucket.
type Job ¶
type Job struct {
Store *store.Store
Disk repos.Disk
GitBinary string
ConfigPath string // copied into each snapshot
LFSRoot string // data/lfs: LFS objects go into each snapshot too (D82)
WorkDir string // temp space on the data disk
Secret secret.Key // auth.secret_key: unseals the bucket secret and the recovery key
HTTP *http.Client
// contains filtered or unexported fields
}
Job runs cloud backups for one install. One run at a time per Job.
func (*Job) Client ¶
func (j *Job) Client(c store.CloudConfig) (*Client, error)
Client builds the S3 client from the stored configuration.