Categorygithub.com/ahab94/grsync
modulepackage
1.0.9
Repository: https://github.com/ahab94/grsync.git
Documentation: pkg.go.dev

# README

grsync — golang rsync wrapper

Build Status codecov GoDoc

Repository contains some helpful tools:

  • raw rsync wrapper
  • rsync task — wrapper which provide important information about rsync task: progress, remain items, total items and speed

Task wrapper usage

package main

import (
    "fmt"
    "grsync"
    "time"
)

func main() {
    task := grsync.NewTask(
        "[email protected]:/source/folder",
        "/home/user/destination",
        grsync.RsyncOptions{},
    )

    go func() {
        for {
            state := task.State()
            fmt.Printf(
                "progress: %.2f / rem. %d / tot. %d / sp. %s \n",
                state.Progress,
                state.Remain,
                state.Total,
                state.Speed,
            )
            time.Sleep(time.Second)
        }
    }()

    if err := task.Run(); err != nil {
        panic(err)
    }

    fmt.Println("well done")
    fmt.Println(task.Log())
}

# Functions

NewCustomRsync returns task with described options.
NewCustomTask returns new rsync task with custom binary.
NewRsync returns task with described options.
NewTask returns new rsync task.

# Structs

Log contains raw stderr and stdout outputs.
Rsync is wrapper under rsync.
RsyncOptions for rsync.
State contains information about rsync process.
Task is high-level API under rsync.