mirror of
https://github.com/octoleo/restic.git
synced 2024-11-26 06:46:34 +00:00
Ignore permission errors for backup
This commit is contained in:
parent
d6a202a853
commit
7d1ba8ab65
11
archiver.go
11
archiver.go
@ -9,6 +9,7 @@ import (
|
|||||||
|
|
||||||
"github.com/fd0/khepri/backend"
|
"github.com/fd0/khepri/backend"
|
||||||
"github.com/fd0/khepri/chunker"
|
"github.com/fd0/khepri/chunker"
|
||||||
|
"github.com/juju/arrar"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -122,7 +123,7 @@ func (arch *Archiver) SaveFile(node *Node) error {
|
|||||||
file, err := os.Open(node.path)
|
file, err := os.Open(node.path)
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return arrar.Annotate(err, "SaveFile()")
|
||||||
}
|
}
|
||||||
|
|
||||||
var blobs Blobs
|
var blobs Blobs
|
||||||
@ -196,7 +197,7 @@ func (arch *Archiver) loadTree(dir string) (*Tree, error) {
|
|||||||
fd, err := os.Open(dir)
|
fd, err := os.Open(dir)
|
||||||
defer fd.Close()
|
defer fd.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, arch.Error(dir, nil, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
entries, err := fd.Readdir(-1)
|
entries, err := fd.Readdir(-1)
|
||||||
@ -247,12 +248,12 @@ func (arch *Archiver) loadTree(dir string) (*Tree, error) {
|
|||||||
func (arch *Archiver) LoadTree(path string) (*Tree, error) {
|
func (arch *Archiver) LoadTree(path string) (*Tree, error) {
|
||||||
fi, err := os.Lstat(path)
|
fi, err := os.Lstat(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, arrar.Annotatef(err, "Lstat(%q)", path)
|
||||||
}
|
}
|
||||||
|
|
||||||
node, err := NodeFromFileInfo(path, fi)
|
node, err := NodeFromFileInfo(path, fi)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, arrar.Annotate(err, "NodeFromFileInfo()")
|
||||||
}
|
}
|
||||||
|
|
||||||
if node.Type != "dir" {
|
if node.Type != "dir" {
|
||||||
@ -265,7 +266,7 @@ func (arch *Archiver) LoadTree(path string) (*Tree, error) {
|
|||||||
arch.Stats.Directories = 1
|
arch.Stats.Directories = 1
|
||||||
node.Tree, err = arch.loadTree(path)
|
node.Tree, err = arch.loadTree(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, arrar.Annotate(err, "loadTree()")
|
||||||
}
|
}
|
||||||
|
|
||||||
arch.ScannerUpdate(arch.Stats)
|
arch.ScannerUpdate(arch.Stats)
|
||||||
|
@ -52,8 +52,9 @@ func commandBackup(be backend.Server, key *khepri.Key, args []string) error {
|
|||||||
fmt.Fprintf(os.Stderr, "err: %v\n", err)
|
fmt.Fprintf(os.Stderr, "err: %v\n", err)
|
||||||
}
|
}
|
||||||
arch.Error = func(dir string, fi os.FileInfo, err error) error {
|
arch.Error = func(dir string, fi os.FileInfo, err error) error {
|
||||||
fmt.Fprintf(os.Stderr, "error for %s: %v\n%v\n", dir, err, fi)
|
// TODO: make ignoring errors configurable
|
||||||
return err
|
fmt.Fprintf(os.Stderr, "\nerror for %s: %v\n%v\n", dir, err, fi)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("scanning %s\n", target)
|
fmt.Printf("scanning %s\n", target)
|
||||||
|
Loading…
Reference in New Issue
Block a user