Documentation
¶
Overview ¶
Package moxrun runs mailbackup steps against a mox container over the Docker API: exec for mox commands, tar copy for staging, and a short-lived helper container for the data swap while mox is stopped.
Index ¶
- Constants
- Variables
- func Fetch(ctx context.Context, ar docker.ArchiveRuntime, ...) error
- func HelperName(app string) string
- func PreRestoreName(id string, now time.Time) string
- func Push(ctx context.Context, rt docker.Runtime, ar docker.ArchiveRuntime, ...) error
- func RemoveStaging(ctx context.Context, rt Execer, containerID, dir string) error
- func ScriptForTest() string
- func StageDir(root, id string) string
- func Sweep(ctx context.Context, rt Execer, containerID, root, minutes string) error
- func ValidID(id string) bool
- func WaitRunning(ctx context.Context, rt docker.Runtime, name string, timeout time.Duration, ...) error
- type ExecRunner
- type Execer
- type Helper
- type Root
- type Volumes
Constants ¶
const ( DataDir = "/mox/data" ConfigDir = "/mox/config" StagingDir = DataDir + "/tmp/backup" // WorkDir holds restore staging and pre-restore copies on the same volume // as the live data (so swaps are renames) but outside tmp, which mox owns. WorkDir = ".levelrail" )
Paths inside the mox container. Staging sits under the data volume so mox can hardlink message files instead of copying them.
Variables ¶
var ErrSwapOpen = errors.New("a restore is in progress or needs recovery")
ErrSwapOpen means a swap journal is open on a mail volume: a restore is running or was interrupted and needs recovery.
Functions ¶
func Fetch ¶
func Fetch(ctx context.Context, ar docker.ArchiveRuntime, containerID, containerDir, hostDir string, maxBytes int64) error
Fetch copies containerDir out of the container into hostDir. maxBytes caps the tar stream so a runaway mailbox cannot fill the control plane disk.
func HelperName ¶
HelperName is the restore helper's container name. Underscores keep it outside every service's "<name>-" container prefix.
func PreRestoreName ¶
PreRestoreName is a unique pre-restore folder name; it sorts by time.
func Push ¶
func Push(ctx context.Context, rt docker.Runtime, ar docker.ArchiveRuntime, containerID, hostDir, containerDir string) error
Push copies hostDir into the container under containerDir/<base of hostDir>, owned by the mox user.
func RemoveStaging ¶
RemoveStaging deletes one staging directory inside the container.
func ScriptForTest ¶
func ScriptForTest() string
ScriptForTest exposes swapScript to the throwaway-container proof.
func Sweep ¶
Sweep removes stale staged and discarded restore dirs under root through the running mail container, hands what is left to the volume owner and removes an empty work dir. It returns ErrSwapOpen while a journal is open.
Types ¶
type ExecRunner ¶
ExecRunner implements mailbackup.Runner with `docker exec <id> mox ...`.
type Execer ¶
type Execer interface {
Exec(ctx context.Context, containerID string, cmd []string) (io.ReadCloser, error)
}
Execer is the exec half of docker.Runtime.
type Helper ¶
type Helper struct {
// contains filtered or unexported fields
}
Helper is a stopped-mail helper container that mounts only the mail volumes and has no network.