archive

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package archive creates compressed tar archives of context data with optional SMB backup.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BackupGlobal

func BackupGlobal(
	w io.Writer, home, timestamp string, smb *SMBConfig,
) (entity.BackupResult, error)

BackupGlobal creates a global-scoped backup archive.

Parameters:

  • w: writer for diagnostic output (typically stderr)
  • home: user home directory
  • timestamp: formatted timestamp for the archive filename
  • smb: optional SMB configuration (nil to skip remote copy)

Returns:

  • BackupResult: archive path, size, and optional SMB destination
  • error: non-nil on archive or SMB failure

func BackupProject

func BackupProject(
	w io.Writer, home, timestamp string, smb *SMBConfig,
) (entity.BackupResult, error)

BackupProject creates a project-scoped backup archive.

Parameters:

  • w: writer for diagnostic output (typically stderr)
  • home: user home directory
  • timestamp: formatted timestamp for the archive filename
  • smb: optional SMB configuration (nil to skip remote copy)

Returns:

  • BackupResult: archive path, size, and optional SMB destination
  • error: non-nil on archive or SMB failure

func CheckBackupMarker

func CheckBackupMarker(markerPath string, warnings []string) []string

CheckBackupMarker checks the backup marker file age and appends warnings when the marker is missing or older than config.BackupMaxAgeDays.

Parameters:

  • markerPath: absolute path to the backup marker file
  • warnings: existing warning slice to append to

Returns:

  • []string: the warnings slice, possibly with staleness warnings appended

func CheckSMBMountWarnings

func CheckSMBMountWarnings(smbURL string, warnings []string) []string

CheckSMBMountWarnings checks whether the GVFS mount for the given SMB URL exists and appends warning strings if the share is not mounted.

Parameters:

  • smbURL: the SMB share URL from the environment
  • warnings: existing warning slice to append to

Returns:

  • []string: the warnings slice, possibly with SMB mount warnings appended

func CopyToSMB

func CopyToSMB(cfg *SMBConfig, localPath string) error

CopyToSMB copies a local file to the SMB share destination directory.

Parameters:

  • cfg: SMB configuration
  • localPath: Path to the local file to copy

Returns:

  • error: Non-nil on copy failure

func CreateArchive

func CreateArchive(
	archivePath string, entries []entity.ArchiveEntry, w io.Writer,
) error

CreateArchive builds a tar.gz archive from the given entries.

Parameters:

  • archivePath: output file path for the archive
  • entries: directories and files to include
  • w: writer for diagnostic output (typically stderr)

Returns:

  • error: non-nil on file creation or tar writing failure

func EnsureSMBMount

func EnsureSMBMount(cfg *SMBConfig) error

EnsureSMBMount checks if the GVFS mount exists and attempts gio mount if not.

Parameters:

  • cfg: SMB configuration

Returns:

  • error: Non-nil if mount fails

Types

type SMBConfig

type SMBConfig struct {
	Host      string
	Share     string
	Subdir    string
	GVFSPath  string
	SourceURL string
}

SMBConfig holds parsed SMB share connection details.

func ParseSMBConfig

func ParseSMBConfig(smbURL, subdir string) (*SMBConfig, error)

ParseSMBConfig parses an SMB URL and subdirectory into a config struct with the derived GVFS mount path.

Parameters:

  • smbURL: SMB share URL (e.g. smb://host/share)
  • subdir: Subdirectory on share (empty uses default)

Returns:

  • *SMBConfig: Parsed config
  • error: Non-nil on invalid URL

Jump to

Keyboard shortcuts

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