grsync

package
v1.15.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: MIT, MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Log

type Log struct {
	Stderr string `json:"stderr"`
	Stdout string `json:"stdout"`
}

Log contains raw rsync standard output and error.

type Rsync

type Rsync struct {
	// source is the transfer source
	Source string
	// destination is the transfer destination
	Destination string
	// contains filtered or unexported fields
}

Rsync wraps one rsync command.

func NewRsync

func NewRsync(
	ctx context.Context,
	source string,
	destination string,
	options RsyncOptions,
) *Rsync

NewRsync constructs an rsync command.

func (Rsync) Run

func (r Rsync) Run() error

Run starts the rsync command and waits for it to finish.

func (Rsync) StderrPipe

func (r Rsync) StderrPipe() (io.ReadCloser, error)

StderrPipe returns a pipe that will be connected to the command's standard error when the command starts.

func (Rsync) StdoutPipe

func (r Rsync) StdoutPipe() (io.ReadCloser, error)

StdoutPipe returns a pipe that will be connected to the command's standard output when the command starts.

type RsyncOptions

type RsyncOptions struct {
	// rsyncBinaryPath overrides the rsync executable path
	RsyncBinaryPath string
	// rsyncPath sets the command used to invoke rsync remotely
	RsyncPath string
	// verbose increases command output
	Verbose bool
	// quiet suppresses non-error messages
	Quiet bool
	// checksum compares file checksums instead of modification time and size
	Checksum bool
	// archive enables archive mode without preserving hard links, ACLs, or xattrs
	Archive bool
	// recursive descends into directories
	Recursive bool
	// relative preserves relative path names
	Relative bool
	// noImpliedDirs omits implied directories when relative mode is enabled
	NoImpliedDirs bool
	// update skips receiver files that are newer
	Update bool
	// inplace updates destination files in place
	Inplace bool
	// append adds data to shorter destination files
	Append bool
	// appendVerify verifies existing data before appending
	AppendVerify bool
	// dirs transfers directories without recursing
	Dirs bool
	// links copies symbolic links as symbolic links
	Links bool
	// copyLinks copies each symbolic-link target
	CopyLinks bool
	// copyUnsafeLinks copies targets of symbolic links that escape the tree
	CopyUnsafeLinks bool
	// safeLinks ignores symbolic links that escape the tree
	SafeLinks bool
	// copyDirLinks copies symbolic links to directories as directories
	CopyDirLinks bool
	// keepDirLinks treats receiver symbolic links to directories as directories
	KeepDirLinks bool
	// hardLinks preserves hard links
	HardLinks bool
	// perms preserves permissions
	Perms bool
	// noPerms disables permission preservation
	NoPerms bool
	// executability preserves executability
	Executability bool
	// chmod changes received file and directory permissions
	CHMOD os.FileMode
	// access-control lists are preserved when enabled
	ACLs bool
	// xattrs preserves extended attributes
	XAttrs bool
	// owner preserves file ownership
	Owner bool
	// noOwner disables owner preservation
	NoOwner bool
	// group preserves group ownership
	Group bool
	// noGroup disables group preservation
	NoGroup bool
	// devices preserves device files
	Devices bool
	// specials preserves special files
	Specials bool
	// times preserves modification times
	Times bool
	// noTimes disables modification-time preservation
	NoTimes bool
	// omitDirTimes omits directories from modification-time preservation
	OmitDirTimes bool
	// super enables receiver super-user activities
	Super bool
	// fakeSuper stores privileged attributes in extended attributes
	FakeSuper bool
	// sparse handles sparse files efficiently
	Sparse bool
	// dryRun reports changes without applying them
	DryRun bool
	// wholeFile disables the delta-transfer algorithm
	WholeFile bool
	// oneFileSystem prevents crossing filesystem boundaries
	OneFileSystem bool
	// blockSize sets the checksum block size
	BlockSize int
	// rsh sets the remote shell command
	Rsh string
	// existing skips creation of receiver files
	Existing bool
	// ignoreExisting skips receiver files that already exist
	IgnoreExisting bool
	// removeSourceFiles removes synchronized source files
	RemoveSourceFiles bool
	// delete removes extraneous destination files
	Delete bool
	// deleteBefore removes destination files before transfer
	DeleteBefore bool
	// deleteDuring removes destination files during transfer
	DeleteDuring bool
	// deleteDelay defers discovered deletions until after transfer
	DeleteDelay bool
	// deleteAfter discovers and removes destination files after transfer
	DeleteAfter bool
	// deleteExcluded also removes excluded destination files
	DeleteExcluded bool
	// ignoreErrors allows deletion despite input or output errors
	IgnoreErrors bool
	// force allows deletion of non-empty directories
	Force bool
	// maxDelete limits the number of deleted files
	MaxDelete int
	// maxSize excludes files larger than this size
	MaxSize int
	// minSize excludes files smaller than this size
	MinSize int
	// partial preserves partially transferred files
	Partial bool
	// partialDir stores partial transfers in this directory
	PartialDir string
	// delayUpdates moves updated files into place after transfer
	DelayUpdates bool
	// pruneEmptyDirs removes empty directory chains from the file list
	PruneEmptyDirs bool
	// numericIDs preserves numeric user and group IDs
	NumericIDs bool
	// timeout sets the input and output timeout in seconds
	Timeout int
	// contimeout sets the daemon connection timeout in seconds
	Contimeout int
	// ignoreTimes transfers files even when size and modification time match
	IgnoreTimes bool
	// sizeOnly compares files by size
	SizeOnly bool
	// modifyWindow selects reduced-accuracy modification-time comparison
	ModifyWindow bool
	// tempDir selects the directory for temporary files
	TempDir string
	// fuzzy searches for a similar receiver file as a transfer basis
	Fuzzy bool
	// compareDest compares receiver files relative to this directory
	CompareDest string
	// copyDest copies unchanged files from this directory
	CopyDest string
	// linkDest hard-links unchanged files from this directory
	LinkDest string
	// compress compresses transferred file data
	Compress bool
	// compressLevel sets the compression level
	CompressLevel int
	// skipCompress excludes matching suffixes from compression
	SkipCompress []string
	// version-control exclusions enable the standard CVS rules
	CVSExclude bool
	// stats emits transfer statistics
	Stats bool
	// humanReadable formats numbers for people
	HumanReadable bool
	// progress emits transfer progress
	Progress bool
	// passwordFile provides the daemon-access password
	PasswordFile string
	// bandwidthLimit limits socket input and output bandwidth
	BandwidthLimit int
	// info selects informational messages
	Info string
	// exclude lists excluded remote paths
	Exclude []string
	// include lists included remote paths
	Include []string
	// filter sets one rsync filter rule
	Filter string
	// chown sets received ownership
	Chown string

	// ipv4 restricts sockets to IPv4
	IPv4 bool
	// ipv6 restricts sockets to IPv6
	IPv6 bool

	// outFormat enables the configured output format
	OutFormat bool
}

RsyncOptions configures an rsync command.

type State

type State struct {
	Remain   int     `json:"remain"`
	Total    int     `json:"total"`
	Speed    string  `json:"speed"`
	Progress float64 `json:"progress"`
}

State describes rsync transfer progress.

type Task

type Task struct {
	// contains filtered or unexported fields
}

Task runs rsync and exposes transfer progress and output.

func NewTask

func NewTask(
	ctx context.Context,
	source string,
	destination string,
	rsyncOptions RsyncOptions,
) *Task

NewTask constructs an rsync task.

func (*Task) Log

func (t *Task) Log() Log

Log returns a snapshot of rsync output.

func (*Task) Run

func (t *Task) Run() error

Run starts rsync and waits for transfer and output processing to finish.

func (*Task) State

func (t *Task) State() State

State returns a snapshot of current rsync progress.

Jump to

Keyboard shortcuts

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