mirror of
https://github.com/octoleo/restic.git
synced 2024-11-10 15:21:03 +00:00
Merge pull request #497 from Thor77/excludeFileExpandEnv
Expand environment-variables in exclude-files
This commit is contained in:
commit
4531456be5
@ -179,7 +179,8 @@ Either specify them with multiple `--exclude`'s or one `--exclude-file`
|
|||||||
|
|
||||||
Patterns use [`filepath.Glob`](https://golang.org/pkg/path/filepath/#Glob) internally,
|
Patterns use [`filepath.Glob`](https://golang.org/pkg/path/filepath/#Glob) internally,
|
||||||
see [`filepath.Match`](https://golang.org/pkg/path/filepath/#Match) for syntax.
|
see [`filepath.Match`](https://golang.org/pkg/path/filepath/#Match) for syntax.
|
||||||
Additionally `**` exludes arbitrary subdirectories.
|
Additionally `**` exludes arbitrary subdirectories.
|
||||||
|
Environment-variables in exclude-files are expanded with [`os.ExpandEnv`](https://golang.org/pkg/os/#ExpandEnv).
|
||||||
|
|
||||||
# List all snapshots
|
# List all snapshots
|
||||||
|
|
||||||
|
@ -6,15 +6,15 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"golang.org/x/crypto/ssh/terminal"
|
|
||||||
"restic"
|
"restic"
|
||||||
"restic/backend"
|
"restic/backend"
|
||||||
"restic/debug"
|
"restic/debug"
|
||||||
"restic/filter"
|
"restic/filter"
|
||||||
"restic/repository"
|
"restic/repository"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"golang.org/x/crypto/ssh/terminal"
|
||||||
)
|
)
|
||||||
|
|
||||||
type CmdBackup struct {
|
type CmdBackup struct {
|
||||||
@ -313,6 +313,7 @@ func (cmd CmdBackup) Execute(args []string) error {
|
|||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
line := scanner.Text()
|
line := scanner.Text()
|
||||||
if !strings.HasPrefix(line, "#") {
|
if !strings.HasPrefix(line, "#") {
|
||||||
|
line = os.ExpandEnv(line)
|
||||||
cmd.Excludes = append(cmd.Excludes, line)
|
cmd.Excludes = append(cmd.Excludes, line)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user