mirror of
https://github.com/octoleo/restic.git
synced 2024-12-02 09:58:25 +00:00
Merge pull request #3877 from MichaelEischer/no-env-in-help
Do not include the actual values of environment variables in help output
This commit is contained in:
commit
3822ded0b3
@ -104,15 +104,12 @@ func init() {
|
|||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
||||||
// parse target pack size from env, on error the default value will be used
|
|
||||||
targetPackSize, _ := strconv.ParseUint(os.Getenv("RESTIC_PACK_SIZE"), 10, 32)
|
|
||||||
|
|
||||||
f := cmdRoot.PersistentFlags()
|
f := cmdRoot.PersistentFlags()
|
||||||
f.StringVarP(&globalOptions.Repo, "repo", "r", os.Getenv("RESTIC_REPOSITORY"), "`repository` to backup to or restore from (default: $RESTIC_REPOSITORY)")
|
f.StringVarP(&globalOptions.Repo, "repo", "r", "", "`repository` to backup to or restore from (default: $RESTIC_REPOSITORY)")
|
||||||
f.StringVarP(&globalOptions.RepositoryFile, "repository-file", "", os.Getenv("RESTIC_REPOSITORY_FILE"), "`file` to read the repository location from (default: $RESTIC_REPOSITORY_FILE)")
|
f.StringVarP(&globalOptions.RepositoryFile, "repository-file", "", "", "`file` to read the repository location from (default: $RESTIC_REPOSITORY_FILE)")
|
||||||
f.StringVarP(&globalOptions.PasswordFile, "password-file", "p", os.Getenv("RESTIC_PASSWORD_FILE"), "`file` to read the repository password from (default: $RESTIC_PASSWORD_FILE)")
|
f.StringVarP(&globalOptions.PasswordFile, "password-file", "p", "", "`file` to read the repository password from (default: $RESTIC_PASSWORD_FILE)")
|
||||||
f.StringVarP(&globalOptions.KeyHint, "key-hint", "", os.Getenv("RESTIC_KEY_HINT"), "`key` ID of key to try decrypting first (default: $RESTIC_KEY_HINT)")
|
f.StringVarP(&globalOptions.KeyHint, "key-hint", "", "", "`key` ID of key to try decrypting first (default: $RESTIC_KEY_HINT)")
|
||||||
f.StringVarP(&globalOptions.PasswordCommand, "password-command", "", os.Getenv("RESTIC_PASSWORD_COMMAND"), "shell `command` to obtain the repository password from (default: $RESTIC_PASSWORD_COMMAND)")
|
f.StringVarP(&globalOptions.PasswordCommand, "password-command", "", "", "shell `command` to obtain the repository password from (default: $RESTIC_PASSWORD_COMMAND)")
|
||||||
f.BoolVarP(&globalOptions.Quiet, "quiet", "q", false, "do not output comprehensive progress report")
|
f.BoolVarP(&globalOptions.Quiet, "quiet", "q", false, "do not output comprehensive progress report")
|
||||||
f.CountVarP(&globalOptions.Verbose, "verbose", "v", "be verbose (specify multiple times or a level using --verbose=`n`, max level/times is 3)")
|
f.CountVarP(&globalOptions.Verbose, "verbose", "v", "be verbose (specify multiple times or a level using --verbose=`n`, max level/times is 3)")
|
||||||
f.BoolVar(&globalOptions.NoLock, "no-lock", false, "do not lock the repository, this allows some operations on read-only repositories")
|
f.BoolVar(&globalOptions.NoLock, "no-lock", false, "do not lock the repository, this allows some operations on read-only repositories")
|
||||||
@ -124,18 +121,26 @@ func init() {
|
|||||||
f.BoolVar(&globalOptions.InsecureTLS, "insecure-tls", false, "skip TLS certificate verification when connecting to the repository (insecure)")
|
f.BoolVar(&globalOptions.InsecureTLS, "insecure-tls", false, "skip TLS certificate verification when connecting to the repository (insecure)")
|
||||||
f.BoolVar(&globalOptions.CleanupCache, "cleanup-cache", false, "auto remove old cache directories")
|
f.BoolVar(&globalOptions.CleanupCache, "cleanup-cache", false, "auto remove old cache directories")
|
||||||
f.Var(&globalOptions.Compression, "compression", "compression mode (only available for repository format version 2), one of (auto|off|max)")
|
f.Var(&globalOptions.Compression, "compression", "compression mode (only available for repository format version 2), one of (auto|off|max)")
|
||||||
f.IntVar(&globalOptions.Limits.UploadKb, "limit-upload", 0, "limits uploads to a maximum rate in KiB/s. (default: unlimited)")
|
f.IntVar(&globalOptions.Limits.UploadKb, "limit-upload", 0, "limits uploads to a maximum `rate` in KiB/s. (default: unlimited)")
|
||||||
f.IntVar(&globalOptions.Limits.DownloadKb, "limit-download", 0, "limits downloads to a maximum rate in KiB/s. (default: unlimited)")
|
f.IntVar(&globalOptions.Limits.DownloadKb, "limit-download", 0, "limits downloads to a maximum `rate` in KiB/s. (default: unlimited)")
|
||||||
f.UintVar(&globalOptions.PackSize, "pack-size", uint(targetPackSize), "set target pack size in MiB, created pack files may be larger (default: $RESTIC_PACK_SIZE)")
|
f.UintVar(&globalOptions.PackSize, "pack-size", 0, "set target pack `size` in MiB, created pack files may be larger (default: $RESTIC_PACK_SIZE)")
|
||||||
f.StringSliceVarP(&globalOptions.Options, "option", "o", []string{}, "set extended option (`key=value`, can be specified multiple times)")
|
f.StringSliceVarP(&globalOptions.Options, "option", "o", []string{}, "set extended option (`key=value`, can be specified multiple times)")
|
||||||
// Use our "generate" command instead of the cobra provided "completion" command
|
// Use our "generate" command instead of the cobra provided "completion" command
|
||||||
cmdRoot.CompletionOptions.DisableDefaultCmd = true
|
cmdRoot.CompletionOptions.DisableDefaultCmd = true
|
||||||
|
|
||||||
|
globalOptions.Repo = os.Getenv("RESTIC_REPOSITORY")
|
||||||
|
globalOptions.RepositoryFile = os.Getenv("RESTIC_REPOSITORY_FILE")
|
||||||
|
globalOptions.PasswordFile = os.Getenv("RESTIC_PASSWORD_FILE")
|
||||||
|
globalOptions.KeyHint = os.Getenv("RESTIC_KEY_HINT")
|
||||||
|
globalOptions.PasswordCommand = os.Getenv("RESTIC_PASSWORD_COMMAND")
|
||||||
comp := os.Getenv("RESTIC_COMPRESSION")
|
comp := os.Getenv("RESTIC_COMPRESSION")
|
||||||
if comp != "" {
|
if comp != "" {
|
||||||
// ignore error as there's no good way to handle it
|
// ignore error as there's no good way to handle it
|
||||||
_ = globalOptions.Compression.Set(comp)
|
_ = globalOptions.Compression.Set(comp)
|
||||||
}
|
}
|
||||||
|
// parse target pack size from env, on error the default value will be used
|
||||||
|
targetPackSize, _ := strconv.ParseUint(os.Getenv("RESTIC_PACK_SIZE"), 10, 32)
|
||||||
|
globalOptions.PackSize = uint(targetPackSize)
|
||||||
|
|
||||||
restoreTerminal()
|
restoreTerminal()
|
||||||
}
|
}
|
||||||
|
@ -24,11 +24,11 @@ type secondaryRepoOptions struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func initSecondaryRepoOptions(f *pflag.FlagSet, opts *secondaryRepoOptions, repoPrefix string, repoUsage string) {
|
func initSecondaryRepoOptions(f *pflag.FlagSet, opts *secondaryRepoOptions, repoPrefix string, repoUsage string) {
|
||||||
f.StringVarP(&opts.LegacyRepo, "repo2", "", os.Getenv("RESTIC_REPOSITORY2"), repoPrefix+" `repository` "+repoUsage+" (default: $RESTIC_REPOSITORY2)")
|
f.StringVarP(&opts.LegacyRepo, "repo2", "", "", repoPrefix+" `repository` "+repoUsage+" (default: $RESTIC_REPOSITORY2)")
|
||||||
f.StringVarP(&opts.LegacyRepositoryFile, "repository-file2", "", os.Getenv("RESTIC_REPOSITORY_FILE2"), "`file` from which to read the "+repoPrefix+" repository location "+repoUsage+" (default: $RESTIC_REPOSITORY_FILE2)")
|
f.StringVarP(&opts.LegacyRepositoryFile, "repository-file2", "", "", "`file` from which to read the "+repoPrefix+" repository location "+repoUsage+" (default: $RESTIC_REPOSITORY_FILE2)")
|
||||||
f.StringVarP(&opts.LegacyPasswordFile, "password-file2", "", os.Getenv("RESTIC_PASSWORD_FILE2"), "`file` to read the "+repoPrefix+" repository password from (default: $RESTIC_PASSWORD_FILE2)")
|
f.StringVarP(&opts.LegacyPasswordFile, "password-file2", "", "", "`file` to read the "+repoPrefix+" repository password from (default: $RESTIC_PASSWORD_FILE2)")
|
||||||
f.StringVarP(&opts.LegacyKeyHint, "key-hint2", "", os.Getenv("RESTIC_KEY_HINT2"), "key ID of key to try decrypting the "+repoPrefix+" repository first (default: $RESTIC_KEY_HINT2)")
|
f.StringVarP(&opts.LegacyKeyHint, "key-hint2", "", "", "key ID of key to try decrypting the "+repoPrefix+" repository first (default: $RESTIC_KEY_HINT2)")
|
||||||
f.StringVarP(&opts.LegacyPasswordCommand, "password-command2", "", os.Getenv("RESTIC_PASSWORD_COMMAND2"), "shell `command` to obtain the "+repoPrefix+" repository password from (default: $RESTIC_PASSWORD_COMMAND2)")
|
f.StringVarP(&opts.LegacyPasswordCommand, "password-command2", "", "", "shell `command` to obtain the "+repoPrefix+" repository password from (default: $RESTIC_PASSWORD_COMMAND2)")
|
||||||
|
|
||||||
// hide repo2 options
|
// hide repo2 options
|
||||||
_ = f.MarkDeprecated("repo2", "use --repo or --from-repo instead")
|
_ = f.MarkDeprecated("repo2", "use --repo or --from-repo instead")
|
||||||
@ -37,11 +37,23 @@ func initSecondaryRepoOptions(f *pflag.FlagSet, opts *secondaryRepoOptions, repo
|
|||||||
_ = f.MarkHidden("key-hint2")
|
_ = f.MarkHidden("key-hint2")
|
||||||
_ = f.MarkHidden("password-command2")
|
_ = f.MarkHidden("password-command2")
|
||||||
|
|
||||||
f.StringVarP(&opts.Repo, "from-repo", "", os.Getenv("RESTIC_FROM_REPOSITORY"), "source `repository` "+repoUsage+" (default: $RESTIC_FROM_REPOSITORY)")
|
opts.LegacyRepo = os.Getenv("RESTIC_REPOSITORY2")
|
||||||
f.StringVarP(&opts.RepositoryFile, "from-repository-file", "", os.Getenv("RESTIC_FROM_REPOSITORY_FILE"), "`file` from which to read the source repository location "+repoUsage+" (default: $RESTIC_FROM_REPOSITORY_FILE)")
|
opts.LegacyRepositoryFile = os.Getenv("RESTIC_REPOSITORY_FILE2")
|
||||||
f.StringVarP(&opts.PasswordFile, "from-password-file", "", os.Getenv("RESTIC_FROM_PASSWORD_FILE"), "`file` to read the source repository password from (default: $RESTIC_FROM_PASSWORD_FILE)")
|
opts.LegacyPasswordFile = os.Getenv("RESTIC_PASSWORD_FILE2")
|
||||||
f.StringVarP(&opts.KeyHint, "from-key-hint", "", os.Getenv("RESTIC_FROM_KEY_HINT"), "key ID of key to try decrypting the source repository first (default: $RESTIC_FROM_KEY_HINT)")
|
opts.LegacyKeyHint = os.Getenv("RESTIC_KEY_HINT2")
|
||||||
f.StringVarP(&opts.PasswordCommand, "from-password-command", "", os.Getenv("RESTIC_FROM_PASSWORD_COMMAND"), "shell `command` to obtain the source repository password from (default: $RESTIC_FROM_PASSWORD_COMMAND)")
|
opts.LegacyPasswordCommand = os.Getenv("RESTIC_PASSWORD_COMMAND2")
|
||||||
|
|
||||||
|
f.StringVarP(&opts.Repo, "from-repo", "", "", "source `repository` "+repoUsage+" (default: $RESTIC_FROM_REPOSITORY)")
|
||||||
|
f.StringVarP(&opts.RepositoryFile, "from-repository-file", "", "", "`file` from which to read the source repository location "+repoUsage+" (default: $RESTIC_FROM_REPOSITORY_FILE)")
|
||||||
|
f.StringVarP(&opts.PasswordFile, "from-password-file", "", "", "`file` to read the source repository password from (default: $RESTIC_FROM_PASSWORD_FILE)")
|
||||||
|
f.StringVarP(&opts.KeyHint, "from-key-hint", "", "", "key ID of key to try decrypting the source repository first (default: $RESTIC_FROM_KEY_HINT)")
|
||||||
|
f.StringVarP(&opts.PasswordCommand, "from-password-command", "", "", "shell `command` to obtain the source repository password from (default: $RESTIC_FROM_PASSWORD_COMMAND)")
|
||||||
|
|
||||||
|
opts.Repo = os.Getenv("RESTIC_FROM_REPOSITORY")
|
||||||
|
opts.RepositoryFile = os.Getenv("RESTIC_FROM_REPOSITORY_FILE")
|
||||||
|
opts.PasswordFile = os.Getenv("RESTIC_FROM_PASSWORD_FILE")
|
||||||
|
opts.KeyHint = os.Getenv("RESTIC_FROM_KEY_HINT")
|
||||||
|
opts.PasswordCommand = os.Getenv("RESTIC_FROM_PASSWORD_COMMAND")
|
||||||
}
|
}
|
||||||
|
|
||||||
func fillSecondaryGlobalOpts(opts secondaryRepoOptions, gopts GlobalOptions, repoPrefix string) (GlobalOptions, bool, error) {
|
func fillSecondaryGlobalOpts(opts secondaryRepoOptions, gopts GlobalOptions, repoPrefix string) (GlobalOptions, bool, error) {
|
||||||
|
@ -54,12 +54,12 @@ Usage help is available:
|
|||||||
--insecure-tls skip TLS certificate verification when connecting to the repository (insecure)
|
--insecure-tls skip TLS certificate verification when connecting to the repository (insecure)
|
||||||
--json set output mode to JSON for commands that support it
|
--json set output mode to JSON for commands that support it
|
||||||
--key-hint key key ID of key to try decrypting first (default: $RESTIC_KEY_HINT)
|
--key-hint key key ID of key to try decrypting first (default: $RESTIC_KEY_HINT)
|
||||||
--limit-download int limits downloads to a maximum rate in KiB/s. (default: unlimited)
|
--limit-download rate limits downloads to a maximum rate in KiB/s. (default: unlimited)
|
||||||
--limit-upload int limits uploads to a maximum rate in KiB/s. (default: unlimited)
|
--limit-upload rate limits uploads to a maximum rate in KiB/s. (default: unlimited)
|
||||||
--pack-size uint set target pack size in MiB. (default: $RESTIC_PACK_SIZE)
|
|
||||||
--no-cache do not use a local cache
|
--no-cache do not use a local cache
|
||||||
--no-lock do not lock the repository, this allows some operations on read-only repositories
|
--no-lock do not lock the repository, this allows some operations on read-only repositories
|
||||||
-o, --option key=value set extended option (key=value, can be specified multiple times)
|
-o, --option key=value set extended option (key=value, can be specified multiple times)
|
||||||
|
--pack-size size set target pack size in MiB, created pack files may be larger (default: $RESTIC_PACK_SIZE)
|
||||||
--password-command command shell command to obtain the repository password from (default: $RESTIC_PASSWORD_COMMAND)
|
--password-command command shell command to obtain the repository password from (default: $RESTIC_PASSWORD_COMMAND)
|
||||||
-p, --password-file file file to read the repository password from (default: $RESTIC_PASSWORD_FILE)
|
-p, --password-file file file to read the repository password from (default: $RESTIC_PASSWORD_FILE)
|
||||||
-q, --quiet do not output comprehensive progress report
|
-q, --quiet do not output comprehensive progress report
|
||||||
@ -91,7 +91,7 @@ command:
|
|||||||
Exit status is 3 if some source data could not be read (incomplete snapshot created).
|
Exit status is 3 if some source data could not be read (incomplete snapshot created).
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
restic backup [flags] FILE/DIR [FILE/DIR] ...
|
restic backup [flags] [FILE/DIR] ...
|
||||||
|
|
||||||
Flags:
|
Flags:
|
||||||
-n, --dry-run do not upload or write any data, just show what would be done
|
-n, --dry-run do not upload or write any data, just show what would be done
|
||||||
@ -127,12 +127,12 @@ command:
|
|||||||
--insecure-tls skip TLS certificate verification when connecting to the repository (insecure)
|
--insecure-tls skip TLS certificate verification when connecting to the repository (insecure)
|
||||||
--json set output mode to JSON for commands that support it
|
--json set output mode to JSON for commands that support it
|
||||||
--key-hint key key ID of key to try decrypting first (default: $RESTIC_KEY_HINT)
|
--key-hint key key ID of key to try decrypting first (default: $RESTIC_KEY_HINT)
|
||||||
--limit-download int limits downloads to a maximum rate in KiB/s. (default: unlimited)
|
--limit-download rate limits downloads to a maximum rate in KiB/s. (default: unlimited)
|
||||||
--limit-upload int limits uploads to a maximum rate in KiB/s. (default: unlimited)
|
--limit-upload rate limits uploads to a maximum rate in KiB/s. (default: unlimited)
|
||||||
--pack-size uint set target pack size in MiB. (default: $RESTIC_PACK_SIZE)
|
|
||||||
--no-cache do not use a local cache
|
--no-cache do not use a local cache
|
||||||
--no-lock do not lock the repository, this allows some operations on read-only repositories
|
--no-lock do not lock the repository, this allows some operations on read-only repositories
|
||||||
-o, --option key=value set extended option (key=value, can be specified multiple times)
|
-o, --option key=value set extended option (key=value, can be specified multiple times)
|
||||||
|
--pack-size size set target pack size in MiB, created pack files may be larger (default: $RESTIC_PACK_SIZE)
|
||||||
--password-command command shell command to obtain the repository password from (default: $RESTIC_PASSWORD_COMMAND)
|
--password-command command shell command to obtain the repository password from (default: $RESTIC_PASSWORD_COMMAND)
|
||||||
-p, --password-file file file to read the repository password from (default: $RESTIC_PASSWORD_FILE)
|
-p, --password-file file file to read the repository password from (default: $RESTIC_PASSWORD_FILE)
|
||||||
-q, --quiet do not output comprehensive progress report
|
-q, --quiet do not output comprehensive progress report
|
||||||
|
Loading…
Reference in New Issue
Block a user