@@ -179,6 +179,12 @@ func init() {
179
179
10 ,
180
180
"the chunk size, in MiB, to use when uploading. A minimum of 5MiB and maximum of 100MiB is enforced." ,
181
181
)
182
+ sendCmd .Flags ().StringVar (
183
+ & jobInfo .LocalVolume ,
184
+ "localVolume" ,
185
+ "" ,
186
+ "the local volume name if different from the S3 volume" ,
187
+ )
182
188
}
183
189
184
190
// ResetSendJobInfo exists solely for integration testing
@@ -248,7 +254,8 @@ func updateJobInfo(args []string) error {
248
254
return errInvalidInput
249
255
}
250
256
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 )
252
259
if err != nil {
253
260
log .AppLogger .Errorf ("Error trying to get creation date of specified base snapshot - %v" , err )
254
261
return err
@@ -257,14 +264,15 @@ func updateJobInfo(args []string) error {
257
264
258
265
if jobInfo .IncrementalSnapshot .Name != "" {
259
266
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 )
261
269
if strings .HasPrefix (jobInfo .IncrementalSnapshot .Name , "#" ) {
262
270
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 )
264
272
jobInfo .IncrementalSnapshot .Bookmark = true
265
273
} else {
266
274
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 )
268
276
}
269
277
270
278
creationTime , err = zfs .GetCreationDate (context .TODO (), targetName )
@@ -304,6 +312,23 @@ func updateJobInfo(args []string) error {
304
312
return nil
305
313
}
306
314
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
+
307
332
func usingSmartOption () bool {
308
333
return jobInfo .Full || jobInfo .Incremental || jobInfo .FullIfOlderThan != - 1 * time .Minute
309
334
}
0 commit comments