fssnap

package
v3.0.0-rc67 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 19 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package fssnap takes read-only, point in time snapshots of the filesystems holding a set of paths, for a copy to read a stable source rather than one written to while it is read, and removes them after the copy, the snapshots a run killed before its end included.

A path is snapshotted with the filesystem mounted deepest under it:

  • a logical volume, thick or thin, whose snapshot is mounted read-only,
  • a btrfs subvolume, whose read-only snapshot is reached through a private mount of the filesystem root,
  • a zfs dataset, whose snapshot is reached in its .zfs directory.

Any other filesystem is refused: a copy asked of a snapshot is not made of the live data instead.

Every mount, logical volume, subvolume and zfs snapshot made is written to a journal before it is made, and Remove undoes the journal, so a run killed before it removed them leaves them to the next one to remove.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Pending

func Pending(dir string) bool

Pending says a run left snapshots for the next one to remove, which a status can tell.

Types

type Set

type Set struct {
	// Dir is the directory of the set, where its journal is kept and
	// its snapshots mounted. It is the set's alone, as the var
	// directory of a resource is.
	Dir string

	// Name names the snapshots, unique to the set among the snapshots
	// of the node: a logical volume, a subvolume and a zfs snapshot
	// are named after it. It holds letters, digits, '_', '.' and '-'.
	Name string

	Log *plog.Logger

	// OneFileSystem says the copy stays on the filesystem of each path,
	// as rsync -x does. Otherwise a filesystem mounted below a path is
	// refused: the snapshot does not hold it, and the copy would take
	// its absence for files to delete.
	OneFileSystem bool
}

Set is the snapshots of one copy, as one run of a sync resource.

func (*Set) Create

func (t *Set) Create(ctx context.Context, paths []string) ([]string, error)

Create snapshots the filesystems holding paths, after removing what a run killed before its end left, and returns the paths as the snapshots show them, in the order given. A path ending with a '/' keeps it, as rsync reads it.

On error, what Create made is left to Remove, which the caller defers as soon as it calls Create.

func (*Set) Remove

func (t *Set) Remove(ctx context.Context) error

Remove undoes what the set made, its journal says, the last made first. What it could not undo stays in the journal, for the next Remove.

func (*Set) RemoveDetached

func (t *Set) RemoveDetached() error

RemoveDetached is Remove with a context of its own, for a deferred call after a context that may be done.

Jump to

Keyboard shortcuts

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