mirror of
https://github.com/octoleo/restic.git
synced 2024-11-26 23:06:32 +00:00
Expand Glob (wildcards character) in paths in file in --files-from
This commit is contained in:
parent
0c0a8e3d2b
commit
e2da0a416c
@ -6,6 +6,7 @@ import (
|
||||
"context"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
@ -301,10 +302,21 @@ func collectTargets(opts BackupOptions, args []string) (targets []string, err er
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// expand wildcards
|
||||
var lines []string
|
||||
for _, line := range fromfile {
|
||||
var expanded []string
|
||||
expanded, err := filepath.Glob(line)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
lines = append(lines, expanded...)
|
||||
}
|
||||
|
||||
// merge files from files-from into normal args so we can reuse the normal
|
||||
// args checks and have the ability to use both files-from and args at the
|
||||
// same time
|
||||
args = append(args, fromfile...)
|
||||
args = append(args, lines...)
|
||||
if len(args) == 0 && !opts.Stdin {
|
||||
return nil, errors.Fatal("nothing to backup, please specify target files/dirs")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user