@@ -179,6 +179,12 @@ func init() {
179179 10 ,
180180 "the chunk size, in MiB, to use when uploading. A minimum of 5MiB and maximum of 100MiB is enforced." ,
181181 )
182+ sendCmd .Flags ().StringVar (
183+ & jobInfo .LocalVolume ,
184+ "localVolume" ,
185+ "" ,
186+ "the local volume name if different from the S3 volume" ,
187+ )
182188}
183189
184190// ResetSendJobInfo exists solely for integration testing
@@ -248,7 +254,8 @@ func updateJobInfo(args []string) error {
248254 return errInvalidInput
249255 }
250256 jobInfo .BaseSnapshot = files.SnapshotInfo {Name : parts [1 ]}
251- creationTime , err := zfs .GetCreationDate (context .TODO (), args [0 ])
257+ localBaseSnapVolumeName := getLocalBaseSnapshotName (args [0 ])
258+ creationTime , err := zfs .GetCreationDate (context .TODO (), localBaseSnapVolumeName )
252259 if err != nil {
253260 log .AppLogger .Errorf ("Error trying to get creation date of specified base snapshot - %v" , err )
254261 return err
@@ -257,14 +264,15 @@ func updateJobInfo(args []string) error {
257264
258265 if jobInfo .IncrementalSnapshot .Name != "" {
259266 var targetName string
260- jobInfo .IncrementalSnapshot .Name = strings .TrimPrefix (jobInfo .IncrementalSnapshot .Name , jobInfo .VolumeName )
267+ localVolumeName := zfs .GetLocalVolumeName (& jobInfo )
268+ jobInfo .IncrementalSnapshot .Name = strings .TrimPrefix (jobInfo .IncrementalSnapshot .Name , localVolumeName )
261269 if strings .HasPrefix (jobInfo .IncrementalSnapshot .Name , "#" ) {
262270 jobInfo .IncrementalSnapshot .Name = strings .TrimPrefix (jobInfo .IncrementalSnapshot .Name , "#" )
263- targetName = fmt .Sprintf ("%s#%s" , jobInfo . VolumeName , jobInfo .IncrementalSnapshot .Name )
271+ targetName = fmt .Sprintf ("%s#%s" , localVolumeName , jobInfo .IncrementalSnapshot .Name )
264272 jobInfo .IncrementalSnapshot .Bookmark = true
265273 } else {
266274 jobInfo .IncrementalSnapshot .Name = strings .TrimPrefix (jobInfo .IncrementalSnapshot .Name , "@" )
267- targetName = fmt .Sprintf ("%s@%s" , jobInfo . VolumeName , jobInfo .IncrementalSnapshot .Name )
275+ targetName = fmt .Sprintf ("%s@%s" , localVolumeName , jobInfo .IncrementalSnapshot .Name )
268276 }
269277
270278 creationTime , err = zfs .GetCreationDate (context .TODO (), targetName )
@@ -304,6 +312,23 @@ func updateJobInfo(args []string) error {
304312 return nil
305313}
306314
315+ // getLocalBaseSnapshotName takes a provided name of the destination snapshot and optionally
316+ // translates it into the local snapshot if --localVolume is given
317+ func getLocalBaseSnapshotName (name string ) string {
318+ var localBaseSnapVolumeName string
319+ if jobInfo .LocalVolume != "" {
320+ argParts := strings .Split (name , "@" )
321+ if len (argParts ) == 2 {
322+ localBaseSnapVolumeName = fmt .Sprintf ("%s@%s" , jobInfo .LocalVolume , argParts [1 ])
323+ } else {
324+ localBaseSnapVolumeName = jobInfo .LocalVolume
325+ }
326+ } else {
327+ localBaseSnapVolumeName = name
328+ }
329+ return localBaseSnapVolumeName
330+ }
331+
307332func usingSmartOption () bool {
308333 return jobInfo .Full || jobInfo .Incremental || jobInfo .FullIfOlderThan != - 1 * time .Minute
309334}
0 commit comments