volumes

package
v1.4.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 4, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package volumes owns the daemon-side volume operations: list, backup, restore, clear — all service-scoped.

Backup format: `podman volume export` produces a tar stream; we pipe it through zstd into $XDG_DATA_HOME/a-novel/backups/<stack>/<service>/<volume>/<ts>.tar.zst. Restore reverses: zstd-decompress + `podman volume import`. Clear is auto-backup (unless --no-backup) + `podman volume rm -f`.

Every destructive op (backup, restore, clear) pre-checks that the service's infra + targets are all down — running ops on a live volume produces inconsistent state. --force overrides after cascade-killing the service first.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Backup

func Backup(svc *discovery.Service, tag string) ([]string, error)

Backup writes a tar.zst archive of every compose-declared volume on the service. `tag`, if non-empty, is embedded in the filename for later identification. Returns the absolute paths of the created archives, one per volume.

Caller is responsible for the pre-check (service down). Backup itself runs unconditionally — the caller decides whether to enforce the safety guard.

func BackupDir

func BackupDir(stack, service, volume string) string

BackupDir is the per-volume backups directory.

func Clear

func Clear(svc *discovery.Service, noBackup bool) ([]string, error)

Clear destroys every volume on the service. When noBackup is false (the default), takes an auto-backup first so undo is one `restore --previous` away. With noBackup=true, deletion is irreversible.

Caller is responsible for the pre-check (service down).

func PodmanVolumeName

func PodmanVolumeName(stack, service, bareVolume string) string

PodmanVolumeName returns the podman-namespaced volume name from a bare compose volume name, following the per-stack convention `<stack>_<service>_<volume>`.

func Restore

func Restore(svc *discovery.Service, from string) ([]string, error)

Restore replaces each volume's contents with a backup archive. `from` selects the archive timestamp; empty means "latest backup for each volume" (the most recent .tar.zst by mtime in the per-volume dir).

Validates the archive (decompress sanity-check) before touching any volume. Returns the list of restored volume names.

Types

type Volume

type Volume struct {
	Name        string // bare name (without stack/service prefix)
	FullName    string // podman volume name (`<stack>_<service>_<name>`)
	Service     string
	Stack       string
	SizeBytes   int64 // 0 if volume doesn't exist yet
	BackupCount int32 // archives in our backups dir
	Exists      bool  // does the podman volume actually exist?
}

Volume is a list-row for `volume list`.

func List

func List(svc *discovery.Service) ([]Volume, error)

List returns one Volume entry per compose-declared volume on the service. Existence + size come from `podman volume inspect`; backup count comes from the backups dir.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL