diff --git a/changelog/unreleased/issue-2040 b/changelog/unreleased/issue-2040 new file mode 100644 index 000000000..b80db6319 --- /dev/null +++ b/changelog/unreleased/issue-2040 @@ -0,0 +1,11 @@ +Bugfix: Add host name filter shorthand flag for `stats` command + +The default value for `--host` flag was set to 'H' (the shorthand version of +the flag), this caused the lookup for the latest snapshot to fail. + +Add shorthand flag `-H` for `--host` (with empty default so if these flags +are not specified the latest snapshot will not filter by host name). + +Also add shorthand `-H` for `backup` command. + +https://github.com/restic/restic/issues/2040 diff --git a/cmd/restic/cmd_backup.go b/cmd/restic/cmd_backup.go index 71f241401..1e47cd50c 100644 --- a/cmd/restic/cmd_backup.go +++ b/cmd/restic/cmd_backup.go @@ -97,7 +97,7 @@ func init() { f.StringVar(&backupOptions.StdinFilename, "stdin-filename", "stdin", "file name to use when reading from stdin") f.StringArrayVar(&backupOptions.Tags, "tag", nil, "add a `tag` for the new snapshot (can be specified multiple times)") - f.StringVar(&backupOptions.Host, "host", "H", "set the `hostname` for the snapshot manually. To prevent an expensive rescan use the \"parent\" flag") + f.StringVarP(&backupOptions.Host, "host", "H", "", "set the `hostname` for the snapshot manually. To prevent an expensive rescan use the \"parent\" flag") f.StringVar(&backupOptions.Host, "hostname", "", "set the `hostname` for the snapshot manually") f.MarkDeprecated("hostname", "use --host") diff --git a/cmd/restic/cmd_stats.go b/cmd/restic/cmd_stats.go index 4e96f9c9e..590ef5f14 100644 --- a/cmd/restic/cmd_stats.go +++ b/cmd/restic/cmd_stats.go @@ -48,7 +48,7 @@ func init() { cmdRoot.AddCommand(cmdStats) f := cmdStats.Flags() f.StringVar(&countMode, "mode", countModeRestoreSize, "counting mode: restore-size (default), files-by-contents, blobs-per-file, or raw-data") - f.StringVar(&snapshotByHost, "host", "H", "filter latest snapshot by this hostname") + f.StringVarP(&snapshotByHost, "host", "H", "", "filter latest snapshot by this hostname") } func runStats(gopts GlobalOptions, args []string) error {