MCPcopy
hub / github.com/restic/restic / newCheckCommand

Function newCheckCommand

cmd/restic/cmd_check.go:27–72  ·  view source on GitHub ↗
(globalOptions *global.Options)

Source from the content-addressed store, hash-verified

25)
26
27func newCheckCommand(globalOptions *global.Options) *cobra.Command {
28 var opts CheckOptions
29 cmd := &cobra.Command{
30 Use: "check [flags]",
31 Short: "Check the repository for errors",
32 Long: `
33The "check" command tests the repository for errors and reports any errors it
34finds.
35
36By default, check verifies the structural consistency and integrity of
37snapshots, trees and pack files. To also verify the integrity of the actual
38backed-up data, use the --read-data or --read-data-subset flags.
39
40By default, check creates a new temporary cache directory to verify data.
41To reuse the existing cache, use the --with-cache flag.
42
43EXIT STATUS
44===========
45
46Exit status is 0 if the command was successful.
47Exit status is 1 if there was any error.
48Exit status is 10 if the repository does not exist.
49Exit status is 11 if the repository is already locked.
50Exit status is 12 if the password is incorrect.
51`,
52 GroupID: cmdGroupDefault,
53 DisableAutoGenTag: true,
54 RunE: func(cmd *cobra.Command, args []string) error {
55 finalizeSnapshotFilter(&opts.SnapshotFilter)
56 summary, err := runCheck(cmd.Context(), opts, *globalOptions, args, globalOptions.Term)
57 if globalOptions.JSON {
58 if err != nil && summary.NumErrors == 0 {
59 summary.NumErrors = 1
60 }
61 globalOptions.Term.Print(ui.ToJSONString(summary))
62 }
63 return err
64 },
65 PreRunE: func(_ *cobra.Command, _ []string) error {
66 return checkFlags(opts)
67 },
68 }
69
70 opts.AddFlags(cmd.Flags())
71 return cmd
72}
73
74// CheckOptions bundles all options for the 'check' command.
75type CheckOptions struct {

Callers 1

newRootCommandFunction · 0.85

Calls 6

AddFlagsMethod · 0.95
ToJSONStringFunction · 0.92
finalizeSnapshotFilterFunction · 0.85
runCheckFunction · 0.85
checkFlagsFunction · 0.85
PrintMethod · 0.65

Tested by

no test coverage detected