Skip to content

Improve help and flags for MongoDB backups #337

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/stackit_mongodbflex_backup_restore.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ Restores a MongoDB Flex instance from a backup

### Synopsis

Restores a MongoDB Flex instance from a backup of an instance or clones a MongoDB Flex instance from a point-in-time snapshot.
The backup is specified by a backup ID and the point-in-time snapshot is specified by a timestamp.
Restores a MongoDB Flex instance from a backup of an instance or clones a MongoDB Flex instance from a point-in-time backup.
The backup can be specified by a backup ID or a timestamp.
You can specify the instance to which the backup will be applied. If not specified, the backup will be applied to the same instance from which it was taken.

```
Expand All @@ -32,7 +32,7 @@ stackit mongodbflex backup restore [flags]
--backup-instance-id string Instance ID of the target instance to restore the backup to
-h, --help Help for "stackit mongodbflex backup restore"
--instance-id string Instance ID
--timestamp string Timestamp of the snapshot to use as a source for cloning the instance in a date-time with the RFC3339 layout format, e.g. 2024-01-01T00:00:00Z
--timestamp string Timestamp to restore the instance to, in a date-time with the RFC3339 layout format, e.g. 2024-01-01T00:00:00Z
```

### Options inherited from parent commands
Expand Down
12 changes: 6 additions & 6 deletions docs/stackit_mongodbflex_backup_update-schedule.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@ stackit mongodbflex backup update-schedule [flags]
Update the backup schedule of a MongoDB Flex instance with ID "xxx"
$ stackit mongodbflex backup update-schedule --instance-id xxx --schedule '6 6 * * *'

Update the retention days for snapshots of a MongoDB Flex instance with ID "xxx" to 5 days
$ stackit mongodbflex backup update-schedule --instance-id xxx --save-snapshot-days 5
Update the retention days for backups of a MongoDB Flex instance with ID "xxx" to 5 days
$ stackit mongodbflex backup update-schedule --instance-id xxx --store-for-days 5
```

### Options

```
-h, --help Help for "stackit mongodbflex backup update-schedule"
--instance-id string Instance ID
--save-daily-snapshot-days int Number of days to retain daily snapshots. Should be less than or equal to the number of days of the selected weekly or monthly value.
--save-monthly-snapshot-months int Number of months to retain monthly snapshots
--save-snapshot-days int Number of days to retain snapshots. Should be less than or equal to the value of the daily backup.
--save-weekly-snapshot-weeks int Number of weeks to retain weekly snapshots. Should be less than or equal to the number of weeks of the selected monthly value.
--schedule string Backup schedule, in the cron scheduling system format e.g. '0 0 * * *'
--store-daily-backup-days int Number of days to retain daily backups. Should be less than or equal to the number of days of the selected weekly or monthly value.
--store-for-days int Number of days to retain backups. Should be less than or equal to the value of the daily backup.
--store-monthly-backups-months int Number of months to retain monthly backups
--store-weekly-backup-weeks int Number of weeks to retain weekly backups. Should be less than or equal to the number of weeks of the selected monthly value.
```

### Options inherited from parent commands
Expand Down
6 changes: 3 additions & 3 deletions internal/cmd/mongodbflex/backup/restore/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ func NewCmd(p *print.Printer) *cobra.Command {
Use: "restore",
Short: "Restores a MongoDB Flex instance from a backup",
Long: fmt.Sprintf("%s\n%s\n%s",
"Restores a MongoDB Flex instance from a backup of an instance or clones a MongoDB Flex instance from a point-in-time snapshot.",
"The backup is specified by a backup ID and the point-in-time snapshot is specified by a timestamp.",
"Restores a MongoDB Flex instance from a backup of an instance or clones a MongoDB Flex instance from a point-in-time backup.",
"The backup can be specified by a backup ID or a timestamp.",
"You can specify the instance to which the backup will be applied. If not specified, the backup will be applied to the same instance from which it was taken.",
),
Args: args.NoArgs,
Expand Down Expand Up @@ -141,7 +141,7 @@ func configureFlags(cmd *cobra.Command) {
cmd.Flags().Var(flags.UUIDFlag(), instanceIdFlag, "Instance ID")
cmd.Flags().Var(flags.UUIDFlag(), backupInstanceIdFlag, "Instance ID of the target instance to restore the backup to")
cmd.Flags().String(backupIdFlag, "", "Backup ID")
cmd.Flags().String(timestampFlag, "", "Timestamp of the snapshot to use as a source for cloning the instance in a date-time with the RFC3339 layout format, e.g. 2024-01-01T00:00:00Z")
cmd.Flags().String(timestampFlag, "", "Timestamp to restore the instance to, in a date-time with the RFC3339 layout format, e.g. 2024-01-01T00:00:00Z")

err := flags.MarkFlagsRequired(cmd, instanceIdFlag)
cobra.CheckErr(err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import (
const (
instanceIdFlag = "instance-id"
scheduleFlag = "schedule"
snapshotRetentionDaysFlag = "save-snapshot-days"
dailySnapshotRetentionDaysFlag = "save-daily-snapshot-days"
weeklySnapshotRetentionWeeksFlag = "save-weekly-snapshot-weeks"
monthlySnapshotRetentionMonthsFlag = "save-monthly-snapshot-months"
snapshotRetentionDaysFlag = "store-for-days"
dailySnapshotRetentionDaysFlag = "store-daily-backup-days"
weeklySnapshotRetentionWeeksFlag = "store-weekly-backup-weeks"
monthlySnapshotRetentionMonthsFlag = "store-monthly-backups-months"

// Default values for the backup schedule options
defaultBackupSchedule = "0 0/6 * * *"
Expand Down Expand Up @@ -62,8 +62,8 @@ func NewCmd(p *print.Printer) *cobra.Command {
`Update the backup schedule of a MongoDB Flex instance with ID "xxx"`,
"$ stackit mongodbflex backup update-schedule --instance-id xxx --schedule '6 6 * * *'"),
examples.NewExample(
`Update the retention days for snapshots of a MongoDB Flex instance with ID "xxx" to 5 days`,
"$ stackit mongodbflex backup update-schedule --instance-id xxx --save-snapshot-days 5"),
`Update the retention days for backups of a MongoDB Flex instance with ID "xxx" to 5 days`,
"$ stackit mongodbflex backup update-schedule --instance-id xxx --store-for-days 5"),
),

RunE: func(cmd *cobra.Command, args []string) error {
Expand Down Expand Up @@ -121,10 +121,10 @@ func NewCmd(p *print.Printer) *cobra.Command {
func configureFlags(cmd *cobra.Command) {
cmd.Flags().Var(flags.UUIDFlag(), instanceIdFlag, "Instance ID")
cmd.Flags().String(scheduleFlag, "", "Backup schedule, in the cron scheduling system format e.g. '0 0 * * *'")
cmd.Flags().Int64(snapshotRetentionDaysFlag, 0, "Number of days to retain snapshots. Should be less than or equal to the value of the daily backup.")
cmd.Flags().Int64(dailySnapshotRetentionDaysFlag, 0, "Number of days to retain daily snapshots. Should be less than or equal to the number of days of the selected weekly or monthly value.")
cmd.Flags().Int64(weeklySnapshotRetentionWeeksFlag, 0, "Number of weeks to retain weekly snapshots. Should be less than or equal to the number of weeks of the selected monthly value.")
cmd.Flags().Int64(monthlySnapshotRetentionMonthsFlag, 0, "Number of months to retain monthly snapshots")
cmd.Flags().Int64(snapshotRetentionDaysFlag, 0, "Number of days to retain backups. Should be less than or equal to the value of the daily backup.")
cmd.Flags().Int64(dailySnapshotRetentionDaysFlag, 0, "Number of days to retain daily backups. Should be less than or equal to the number of days of the selected weekly or monthly value.")
cmd.Flags().Int64(weeklySnapshotRetentionWeeksFlag, 0, "Number of weeks to retain weekly backups. Should be less than or equal to the number of weeks of the selected monthly value.")
cmd.Flags().Int64(monthlySnapshotRetentionMonthsFlag, 0, "Number of months to retain monthly backups")

err := flags.MarkFlagsRequired(cmd, instanceIdFlag)
cobra.CheckErr(err)
Expand Down