MCPcopy Create free account
hub / github.com/opencloud-eu/opencloud / ConsistencyCommand

Function ConsistencyCommand

opencloud/pkg/command/backup.go:32–78  ·  view source on GitHub ↗

ConsistencyCommand is the entrypoint for the consistency Command

(cfg *config.Config)

Source from the content-addressed store, hash-verified

30
31// ConsistencyCommand is the entrypoint for the consistency Command
32func ConsistencyCommand(cfg *config.Config) *cobra.Command {
33 consCmd := &cobra.Command{
34 Use: "consistency",
35 Short: "check backup consistency",
36 RunE: func(cmd *cobra.Command, args []string) error {
37 var (
38 bs backup.ListBlobstore
39 err error
40 )
41 basePath, _ := cmd.Flags().GetString("basepath")
42 blobstoreFlag, _ := cmd.Flags().GetString("blobstore")
43 switch blobstoreFlag {
44 case "decomposeds3":
45 bs, err = decomposeds3bs.New(
46 cfg.StorageUsers.Drivers.DecomposedS3.Endpoint,
47 cfg.StorageUsers.Drivers.DecomposedS3.Region,
48 cfg.StorageUsers.Drivers.DecomposedS3.Bucket,
49 cfg.StorageUsers.Drivers.DecomposedS3.AccessKey,
50 cfg.StorageUsers.Drivers.DecomposedS3.SecretKey,
51 decomposeds3bs.Options{},
52 )
53 case "decomposed":
54 bs, err = decomposedbs.New(basePath)
55 case "none":
56 bs = nil
57 default:
58 err = errors.New("blobstore type not supported")
59 }
60 if err != nil {
61 fmt.Println(err)
62 return err
63 }
64 fail, _ := cmd.Flags().GetBool("fail")
65 if err := backup.CheckProviderConsistency(basePath, bs, fail); err != nil {
66 fmt.Println(err)
67 return err
68 }
69
70 return nil
71 },
72 }
73 consCmd.Flags().StringP("basepath", "p", "", "the basepath of the decomposedfs (e.g. /var/tmp/opencloud/storage/users)")
74 _ = consCmd.MarkFlagRequired("basepath")
75 consCmd.Flags().StringP("blobstore", "b", "decomposed", "the blobstore type. Can be (none, decomposed, decomposeds3). Default decomposed")
76 consCmd.Flags().Bool("fail", false, "exit with non-zero status if consistency check fails")
77 return consCmd
78}
79
80func init() {
81 register.AddCommand(BackupCommand)

Callers 1

BackupCommandFunction · 0.85

Calls 1

CheckProviderConsistencyFunction · 0.92

Tested by

no test coverage detected