Add verify CLI and readonly flag
Add a backup subcommand to verify that backup snapshots are present and wire up the readonly flag.
This commit is contained in:
parent
1694581e26
commit
651714fb4c
@ -63,6 +63,14 @@ func AddCommands(cmd *cobra.Command) {
|
|||||||
flags.AddAllStorageFlags(sc)
|
flags.AddAllStorageFlags(sc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add verify command separately. It's not bound to a single service.
|
||||||
|
verifyCommand := verifyCmd()
|
||||||
|
flags.AddAllProviderFlags(verifyCommand)
|
||||||
|
flags.AddAllStorageFlags(verifyCommand)
|
||||||
|
flags.AddReadOnlyFlag(verifyCommand)
|
||||||
|
|
||||||
|
backupC.AddCommand(verifyCommand)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
@ -163,6 +171,42 @@ func handleDeleteCmd(cmd *cobra.Command, args []string) error {
|
|||||||
return cmd.Help()
|
return cmd.Help()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The backup verify subcommand.
|
||||||
|
// `corso backup verify`
|
||||||
|
var verifyCommand = "verify"
|
||||||
|
|
||||||
|
func verifyCmd() *cobra.Command {
|
||||||
|
return &cobra.Command{
|
||||||
|
Use: verifyCommand,
|
||||||
|
Short: "Verifies all backups have all their data",
|
||||||
|
RunE: handleVerifyCmd,
|
||||||
|
Args: cobra.NoArgs,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handler for calls to `corso backup delete`.
|
||||||
|
// Produces the same output as `corso backup delete --help`.
|
||||||
|
func handleVerifyCmd(cmd *cobra.Command, args []string) error {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
|
||||||
|
r, _, err := utils.AccountConnectAndWriteRepoConfig(
|
||||||
|
ctx,
|
||||||
|
cmd,
|
||||||
|
// Service doesn't really matter but we need to give it something valid.
|
||||||
|
path.OneDriveService)
|
||||||
|
if err != nil {
|
||||||
|
return Only(ctx, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
defer utils.CloseRepo(ctx, r)
|
||||||
|
|
||||||
|
if err := r.VerifyBackups(ctx); err != nil {
|
||||||
|
return Only(ctx, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// common handlers
|
// common handlers
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|||||||
@ -14,6 +14,7 @@ const (
|
|||||||
// Corso Flags
|
// Corso Flags
|
||||||
PassphraseFN = "passphrase"
|
PassphraseFN = "passphrase"
|
||||||
NewPassphraseFN = "new-passphrase"
|
NewPassphraseFN = "new-passphrase"
|
||||||
|
ReadOnlyFN = "readonly"
|
||||||
SucceedIfExistsFN = "succeed-if-exists"
|
SucceedIfExistsFN = "succeed-if-exists"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -25,6 +26,7 @@ var (
|
|||||||
AWSSessionTokenFV string
|
AWSSessionTokenFV string
|
||||||
PassphraseFV string
|
PassphraseFV string
|
||||||
NewPhasephraseFV string
|
NewPhasephraseFV string
|
||||||
|
ReadOnlyFV bool
|
||||||
SucceedIfExistsFV bool
|
SucceedIfExistsFV bool
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -59,6 +61,13 @@ func AddAllStorageFlags(cmd *cobra.Command) {
|
|||||||
AddAWSCredsFlags(cmd)
|
AddAWSCredsFlags(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func AddReadOnlyFlag(cmd *cobra.Command) {
|
||||||
|
fs := cmd.Flags()
|
||||||
|
fs.BoolVar(&ReadOnlyFV, ReadOnlyFN, false, "open repository in read-only mode")
|
||||||
|
//nolint:errcheck
|
||||||
|
fs.MarkHidden(ReadOnlyFN)
|
||||||
|
}
|
||||||
|
|
||||||
func AddAWSCredsFlags(cmd *cobra.Command) {
|
func AddAWSCredsFlags(cmd *cobra.Command) {
|
||||||
fs := cmd.Flags()
|
fs := cmd.Flags()
|
||||||
fs.StringVar(&AWSAccessKeyFV, AWSAccessKeyFN, "", "S3 access key")
|
fs.StringVar(&AWSAccessKeyFV, AWSAccessKeyFN, "", "S3 access key")
|
||||||
|
|||||||
@ -30,6 +30,7 @@ func Control() control.Options {
|
|||||||
opt.ToggleFeatures.ExchangeImmutableIDs = flags.EnableImmutableIDFV
|
opt.ToggleFeatures.ExchangeImmutableIDs = flags.EnableImmutableIDFV
|
||||||
opt.ToggleFeatures.UseDeltaTree = flags.UseDeltaTreeFV
|
opt.ToggleFeatures.UseDeltaTree = flags.UseDeltaTreeFV
|
||||||
opt.Parallelism.ItemFetch = flags.FetchParallelismFV
|
opt.Parallelism.ItemFetch = flags.FetchParallelismFV
|
||||||
|
opt.Repo.ReadOnly = flags.ReadOnlyFV
|
||||||
|
|
||||||
return opt
|
return opt
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user