mirror of
https://github.com/restic/restic.git
synced 2026-06-25 10:04:17 +00:00
add --disable-scanner to backup command
The scanner process has only cosmetic effect for the progress printer, and can be disabled without impacting functionality when the user does not need an estimate of completion. In many cases the scanner process can provide beneficial priming of the file system cache, so as general advice it should not be disabled. However, tests have shown that backup of NFS and fuse based filesystems, where stat(2) is relatively expensive, can be significantly faster without the scanner.
This commit is contained in:
committed by
Michael Eischer
parent
7bdb985dde
commit
14aa6f2a00
@@ -99,6 +99,7 @@ type BackupOptions struct {
|
||||
UseFsSnapshot bool
|
||||
DryRun bool
|
||||
ReadConcurrency uint
|
||||
NoScan bool
|
||||
}
|
||||
|
||||
var backupOptions BackupOptions
|
||||
@@ -138,6 +139,7 @@ func init() {
|
||||
f.BoolVar(&backupOptions.IgnoreInode, "ignore-inode", false, "ignore inode number changes when checking for modified files")
|
||||
f.BoolVar(&backupOptions.IgnoreCtime, "ignore-ctime", false, "ignore ctime changes when checking for modified files")
|
||||
f.BoolVarP(&backupOptions.DryRun, "dry-run", "n", false, "do not upload or write any data, just show what would be done")
|
||||
f.BoolVar(&backupOptions.NoScan, "no-scan", false, "do not run scanner to estimate size of backup")
|
||||
if runtime.GOOS == "windows" {
|
||||
f.BoolVar(&backupOptions.UseFsSnapshot, "use-fs-snapshot", false, "use filesystem snapshot where possible (currently only Windows VSS)")
|
||||
}
|
||||
@@ -586,16 +588,18 @@ func runBackup(ctx context.Context, opts BackupOptions, gopts GlobalOptions, ter
|
||||
targets = []string{filename}
|
||||
}
|
||||
|
||||
sc := archiver.NewScanner(targetFS)
|
||||
sc.SelectByName = selectByNameFilter
|
||||
sc.Select = selectFilter
|
||||
sc.Error = progressPrinter.ScannerError
|
||||
sc.Result = progressReporter.ReportTotal
|
||||
if !opts.NoScan {
|
||||
sc := archiver.NewScanner(targetFS)
|
||||
sc.SelectByName = selectByNameFilter
|
||||
sc.Select = selectFilter
|
||||
sc.Error = progressPrinter.ScannerError
|
||||
sc.Result = progressReporter.ReportTotal
|
||||
|
||||
if !gopts.JSON {
|
||||
progressPrinter.V("start scan on %v", targets)
|
||||
if !gopts.JSON {
|
||||
progressPrinter.V("start scan on %v", targets)
|
||||
}
|
||||
wg.Go(func() error { return sc.Scan(cancelCtx, targets) })
|
||||
}
|
||||
wg.Go(func() error { return sc.Scan(cancelCtx, targets) })
|
||||
|
||||
arch := archiver.New(repo, targetFS, archiver.Options{ReadConcurrency: backupOptions.ReadConcurrency})
|
||||
arch.SelectByName = selectByNameFilter
|
||||
|
||||
Reference in New Issue
Block a user