mirror of
https://github.com/zrepl/zrepl.git
synced 2025-06-22 10:41:40 +02: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 {
|
if s.from == nil {
|
||||||
sr = &pdu.SendReq{
|
sr = &pdu.SendReq{
|
||||||
Filesystem: fs,
|
Filesystem: fs,
|
||||||
From: s.to.RelName(), // FIXME fix protocol to use To, like zfs does internally
|
To: s.to.RelName(),
|
||||||
DryRun: dryRun,
|
DryRun: dryRun,
|
||||||
}
|
}
|
||||||
} else {
|
} 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
|
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) {
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
toV := ""
|
fromV := ""
|
||||||
if to != "" {
|
if from != "" {
|
||||||
toV, err = absVersion(fs, to)
|
fromV, err = absVersion(fs, from)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -304,8 +305,8 @@ func ZFSSend(fs string, from, to string) (stream io.ReadCloser, err error) {
|
|||||||
args := make([]string, 0)
|
args := make([]string, 0)
|
||||||
args = append(args, "send")
|
args = append(args, "send")
|
||||||
|
|
||||||
if toV == "" { // Initial
|
if fromV == "" { // Initial
|
||||||
args = append(args, fromV)
|
args = append(args, toV)
|
||||||
} else {
|
} else {
|
||||||
args = append(args, "-i", fromV, toV)
|
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")
|
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.
|
// May return BookmarkSizeEstimationNotSupported as err if from is a bookmark.
|
||||||
func ZFSSendDry(fs string, from, to string) (size int64, err error) {
|
func ZFSSendDry(fs string, from, to string) (size int64, err error) {
|
||||||
|
|
||||||
fromV, err := absVersion(fs, from)
|
toV, err := absVersion(fs, to)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
toV := ""
|
fromV := ""
|
||||||
if to != "" {
|
if from != "" {
|
||||||
toV, err = absVersion(fs, to)
|
fromV, err = absVersion(fs, from)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
@ -346,8 +348,8 @@ func ZFSSendDry(fs string, from, to string) (size int64, err error) {
|
|||||||
args := make([]string, 0)
|
args := make([]string, 0)
|
||||||
args = append(args, "send", "-n", "-v", "-P")
|
args = append(args, "send", "-n", "-v", "-P")
|
||||||
|
|
||||||
if toV == "" { // Initial
|
if fromV == "" {
|
||||||
args = append(args, fromV)
|
args = append(args, toV)
|
||||||
} else {
|
} else {
|
||||||
args = append(args, "-i", fromV, toV)
|
args = append(args, "-i", fromV, toV)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user