docker

package
v0.0.0-...-ba7b047 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2025 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DockerClient

type DockerClient struct {
	Client *client.Client
}

func NewDockerClient

func NewDockerClient() (*DockerClient, error)

func (*DockerClient) BackupVolume

func (d *DockerClient) BackupVolume(ctx context.Context, volumeName string, backupPath string) error

BackupVolume creates a backup of the Docker volume identified by volumeName. It does so by launching a temporary container using the "alpine" image that mounts the specified volume at "/data". Within the container, it runs a tar command to compress the contents of the volume into a gzip archive. The function collects the container's output (which is the tarball data) from the container logs, writes this output to a file specified by backupPath, and then cleans up by removing the temporary container. Any errors encountered during container creation, starting, log retrieval, file operations, or data copying are returned accordingly.

func (*DockerClient) RestoreVolume

func (d *DockerClient) RestoreVolume(ctx context.Context, volumeName string, backupPath string) error

RestoreVolume restores the contents of a Docker volume from a backup file. It creates a temporary container with a mounted volume and uses the tar utility to extract the backup data into the volume. Parameters:

  • ctx: The context for managing the lifecycle of the restore operation.
  • volumeName: The name of the Docker volume to restore.
  • backupPath: The file system path to the backup file (a tar.gz archive) containing the volume data.

Returns:

An error if the restore operation fails at any step, otherwise nil.

Jump to

Keyboard shortcuts

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