mirror of
https://github.com/zrepl/zrepl.git
synced 2024-11-22 08:23:50 +01:00
replication + zfs: leave From field instead of To field empty for initial send
This commit is contained in:
parent
f13749380d
commit
3c06235dca
@ -485,7 +485,7 @@ func (s *ReplicationStep) buildSendRequest(dryRun bool) (sr *pdu.SendReq) {
|
||||
if s.from == nil {
|
||||
sr = &pdu.SendReq{
|
||||
Filesystem: fs,
|
||||
From: s.to.RelName(), // FIXME fix protocol to use To, like zfs does internally
|
||||
To: s.to.RelName(),
|
||||
DryRun: dryRun,
|
||||
}
|
||||
} else {
|
||||
|
26
zfs/zfs.go
26
zfs/zfs.go
@ -286,16 +286,17 @@ func absVersion(fs, v string) (full string, err error) {
|
||||
return fmt.Sprintf("%s%s", fs, v), nil
|
||||
}
|
||||
|
||||
// from may be "", in which case a full ZFS send is done
|
||||
func ZFSSend(fs string, from, to string) (stream io.ReadCloser, err error) {
|
||||
|
||||
fromV, err := absVersion(fs, from)
|
||||
toV, err := absVersion(fs, to)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
toV := ""
|
||||
if to != "" {
|
||||
toV, err = absVersion(fs, to)
|
||||
fromV := ""
|
||||
if from != "" {
|
||||
fromV, err = absVersion(fs, from)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -304,8 +305,8 @@ func ZFSSend(fs string, from, to string) (stream io.ReadCloser, err error) {
|
||||
args := make([]string, 0)
|
||||
args = append(args, "send")
|
||||
|
||||
if toV == "" { // Initial
|
||||
args = append(args, fromV)
|
||||
if fromV == "" { // Initial
|
||||
args = append(args, toV)
|
||||
} else {
|
||||
args = append(args, "-i", fromV, toV)
|
||||
}
|
||||
@ -317,17 +318,18 @@ func ZFSSend(fs string, from, to string) (stream io.ReadCloser, err error) {
|
||||
|
||||
var BookmarkSizeEstimationNotSupported error = fmt.Errorf("size estimation is not supported for bookmarks")
|
||||
|
||||
// from may be "", in which case a full ZFS send is done
|
||||
// May return BookmarkSizeEstimationNotSupported as err if from is a bookmark.
|
||||
func ZFSSendDry(fs string, from, to string) (size int64, err error) {
|
||||
|
||||
fromV, err := absVersion(fs, from)
|
||||
toV, err := absVersion(fs, to)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
toV := ""
|
||||
if to != "" {
|
||||
toV, err = absVersion(fs, to)
|
||||
fromV := ""
|
||||
if from != "" {
|
||||
fromV, err = absVersion(fs, from)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
@ -346,8 +348,8 @@ func ZFSSendDry(fs string, from, to string) (size int64, err error) {
|
||||
args := make([]string, 0)
|
||||
args = append(args, "send", "-n", "-v", "-P")
|
||||
|
||||
if toV == "" { // Initial
|
||||
args = append(args, fromV)
|
||||
if fromV == "" {
|
||||
args = append(args, toV)
|
||||
} else {
|
||||
args = append(args, "-i", fromV, toV)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user