Merge pull request #3931 from kjetilho/feature/optional_scanner

add --no-scan to backup command
This commit is contained in:
Michael Eischer 2022-12-16 21:42:22 +01:00 committed by GitHub
commit 2723159ed4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 9 deletions

View file

@ -0,0 +1,8 @@
Enhancement: Allow backup file tree scanner to be disabled
Restic walks the file tree in a separate scanner process to find the total size
and file/directory count, and uses that to provide an ETA. This can slow down
backups, especially of network filesystems. The new flag `--no-scan`
can be used to speed up such backups.
https://github.com/restic/restic/pull/3931

View file

@ -99,6 +99,7 @@ type BackupOptions struct {
UseFsSnapshot bool UseFsSnapshot bool
DryRun bool DryRun bool
ReadConcurrency uint ReadConcurrency uint
NoScan bool
} }
var backupOptions BackupOptions 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.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.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.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" { if runtime.GOOS == "windows" {
f.BoolVar(&backupOptions.UseFsSnapshot, "use-fs-snapshot", false, "use filesystem snapshot where possible (currently only Windows VSS)") f.BoolVar(&backupOptions.UseFsSnapshot, "use-fs-snapshot", false, "use filesystem snapshot where possible (currently only Windows VSS)")
} }
@ -586,6 +588,7 @@ func runBackup(ctx context.Context, opts BackupOptions, gopts GlobalOptions, ter
targets = []string{filename} targets = []string{filename}
} }
if !opts.NoScan {
sc := archiver.NewScanner(targetFS) sc := archiver.NewScanner(targetFS)
sc.SelectByName = selectByNameFilter sc.SelectByName = selectByNameFilter
sc.Select = selectFilter sc.Select = selectFilter
@ -596,6 +599,7 @@ func runBackup(ctx context.Context, opts BackupOptions, gopts GlobalOptions, ter
progressPrinter.V("start scan on %v", targets) 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 := archiver.New(repo, targetFS, archiver.Options{ReadConcurrency: backupOptions.ReadConcurrency})
arch.SelectByName = selectByNameFilter arch.SelectByName = selectByNameFilter

View file

@ -204,8 +204,17 @@ Combined with ``--verbose``, you can see a list of changes:
modified /archive.tar.gz, saved in 0.140s (25.542 MiB added) modified /archive.tar.gz, saved in 0.140s (25.542 MiB added)
Would be added to the repository: 25.551 MiB Would be added to the repository: 25.551 MiB
.. _backup-excluding-files: Disabling Backup Progress Estimation
************************************
When you start a backup, restic will concurrently count the number of
files and their total size, which is used to estimate how long it will
take. This will cause some extra I/O, which can slow down backup of
network file systems or fuse mounts.
- ``--no-scan`` Do not run scanner to estimate size of backup
.. _backup-excluding-files:
Excluding Files Excluding Files
*************** ***************