blob: 82985898996b4d352de6a78c59944a99109d6166 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
package service
import (
"bytes"
"errors"
"net/url"
"os/exec"
"strings"
)
var rsyncOpts = []string{
"--delete-excluded",
"--hard-links",
"--links",
"--perms",
"--recursive",
"--safe-links",
"--sparse",
"--times",
}
func Rsync(dst *url.URL, src *url.URL) error {
src2 := *src
if !strings.HasSuffix(src2.Path, "/.") {
src2.Path = src2.Path + "/."
}
var stderr bytes.Buffer
args := append(rsyncOpts, src2.String(), dst.String())
cmd := exec.Command("rsync", args...)
cmd.Stderr = &stderr
err := cmd.Run()
if err != nil {
return errors.New(stderr.String())
}
return nil
}
|