Add a -max-list-rate option to backup to slow down the listing

This option sets the maximum number of files that can be listed in one
second.
This commit is contained in:
Gilbert Chen
2020-09-22 08:27:09 -04:00
parent 6ee01a2e74
commit 67a3103467
5 changed files with 31 additions and 12 deletions

View File

@@ -745,13 +745,14 @@ func backupRepository(context *cli.Context) {
dryRun := context.Bool("dry-run")
uploadRateLimit := context.Int("limit-rate")
enumOnly := context.Bool("enum-only")
listRateLimit := context.Int("max-list-rate")
storage.SetRateLimits(0, uploadRateLimit)
backupManager := duplicacy.CreateBackupManager(preference.SnapshotID, storage, repository, password, preference.NobackupFile, preference.FiltersFile)
duplicacy.SavePassword(*preference, "password", password)
backupManager.SetupSnapshotCache(preference.Name)
backupManager.SetDryRun(dryRun)
backupManager.Backup(repository, quickMode, threads, context.String("t"), showStatistics, enableVSS, vssTimeout, enumOnly)
backupManager.Backup(repository, quickMode, threads, context.String("t"), showStatistics, enableVSS, vssTimeout, enumOnly, listRateLimit)
runScript(context, preference.Name, "post")
}
@@ -1465,6 +1466,13 @@ func main() {
Name: "enum-only",
Usage: "enumerate the repository recursively and then exit",
},
cli.IntFlag{
Name: "max-list-rate",
Value: 0,
Usage: "the maximum number of files to list in one second",
Argument: "<number>",
},
},
Usage: "Save a snapshot of the repository to the storage",
ArgsUsage: " ",