Skip to content

Commit 107b90d

Browse files
authored
Mongodb backup schedule, update-schedule, restore (#316)
* initial update schedule implementation * implement update and list schedule commands, add testing * restore command and testing * add waiters * generate docs * merge changes * address PR comments * add custom error, fix restore examples
1 parent 848400e commit 107b90d

16 files changed

+1590
-6
lines changed

docs/stackit_mongodbflex_backup.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,8 @@ stackit mongodbflex backup [flags]
3131
* [stackit mongodbflex](./stackit_mongodbflex.md) - Provides functionality for MongoDB Flex
3232
* [stackit mongodbflex backup describe](./stackit_mongodbflex_backup_describe.md) - Shows details of a backup for a MongoDB Flex instance
3333
* [stackit mongodbflex backup list](./stackit_mongodbflex_backup_list.md) - Lists all backups which are available for a MongoDB Flex instance
34+
* [stackit mongodbflex backup restore](./stackit_mongodbflex_backup_restore.md) - Restores a MongoDB Flex instance from a backup
3435
* [stackit mongodbflex backup restore-jobs](./stackit_mongodbflex_backup_restore-jobs.md) - Lists all restore jobs which have been run for a MongoDB Flex instance
36+
* [stackit mongodbflex backup schedule](./stackit_mongodbflex_backup_schedule.md) - Shows details of the backup schedule and retention policy of a MongoDB Flex instance
37+
* [stackit mongodbflex backup update-schedule](./stackit_mongodbflex_backup_update-schedule.md) - Updates the backup schedule and retention policy for a MongoDB Flex instance
3538

docs/stackit_mongodbflex_backup_restore-jobs.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ stackit mongodbflex backup restore-jobs [flags]
1414

1515
```
1616
List all restore jobs of instance with ID "xxx"
17-
$ stackit mongodbflex backup list --instance-id xxx
17+
$ stackit mongodbflex backup restore-jobs --instance-id xxx
1818
1919
List all restore jobs of instance with ID "xxx" in JSON format
20-
$ stackit mongodbflex backup list --instance-id xxx --output-format json
20+
$ stackit mongodbflex backup restore-jobs --instance-id xxx --output-format json
2121
2222
List up to 10 restore jobs of instance with ID "xxx"
23-
$ stackit mongodbflex backup list --instance-id xxx --limit 10
23+
$ stackit mongodbflex backup restore-jobs --instance-id xxx --limit 10
2424
```
2525

2626
### Options
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
## stackit mongodbflex backup restore
2+
3+
Restores a MongoDB Flex instance from a backup
4+
5+
### Synopsis
6+
7+
Restores a MongoDB Flex instance from a backup of an instance or clones a MongoDB Flex instance from a point-in-time snapshot.
8+
The backup is specified by a backup ID and the point-in-time snapshot is specified by a timestamp.
9+
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.
10+
11+
```
12+
stackit mongodbflex backup restore [flags]
13+
```
14+
15+
### Examples
16+
17+
```
18+
Restore a MongoDB Flex instance with ID "yyy" using backup with ID "zzz"
19+
$ stackit mongodbflex backup restore --instance-id yyy --backup-id zzz
20+
21+
Clone a MongoDB Flex instance with ID "yyy" via point-in-time restore to timestamp "2024-05-14T14:31:48Z"
22+
$ stackit mongodbflex backup restore --instance-id yyy --timestamp 2024-05-14T14:31:48Z
23+
24+
Restore a MongoDB Flex instance with ID "yyy", using backup from instance with ID "zzz" with backup ID "xxx"
25+
$ stackit mongodbflex backup restore --instance-id zzz --backup-instance-id yyy --backup-id xxx
26+
```
27+
28+
### Options
29+
30+
```
31+
--backup-id string Backup ID
32+
--backup-instance-id string Instance ID of the target instance to restore the backup to
33+
-h, --help Help for "stackit mongodbflex backup restore"
34+
--instance-id string Instance ID
35+
--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
36+
```
37+
38+
### Options inherited from parent commands
39+
40+
```
41+
-y, --assume-yes If set, skips all confirmation prompts
42+
--async If set, runs the command asynchronously
43+
-o, --output-format string Output format, one of ["json" "pretty" "none"]
44+
-p, --project-id string Project ID
45+
--verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info")
46+
```
47+
48+
### SEE ALSO
49+
50+
* [stackit mongodbflex backup](./stackit_mongodbflex_backup.md) - Provides functionality for MongoDB Flex instance backups
51+
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
## stackit mongodbflex backup schedule
2+
3+
Shows details of the backup schedule and retention policy of a MongoDB Flex instance
4+
5+
### Synopsis
6+
7+
Shows details of the backup schedule and retention policy of a MongoDB Flex instance.
8+
9+
```
10+
stackit mongodbflex backup schedule [flags]
11+
```
12+
13+
### Examples
14+
15+
```
16+
Get details of the backup schedule of a MongoDB Flex instance with ID "xxx"
17+
$ stackit mongodbflex backup schedule --instance-id xxx
18+
19+
Get details of the backup schedule of a MongoDB Flex instance with ID "xxx" in JSON format
20+
$ stackit mongodbflex backup schedule --instance-id xxx --output-format json
21+
```
22+
23+
### Options
24+
25+
```
26+
-h, --help Help for "stackit mongodbflex backup schedule"
27+
--instance-id string Instance ID
28+
```
29+
30+
### Options inherited from parent commands
31+
32+
```
33+
-y, --assume-yes If set, skips all confirmation prompts
34+
--async If set, runs the command asynchronously
35+
-o, --output-format string Output format, one of ["json" "pretty" "none"]
36+
-p, --project-id string Project ID
37+
--verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info")
38+
```
39+
40+
### SEE ALSO
41+
42+
* [stackit mongodbflex backup](./stackit_mongodbflex_backup.md) - Provides functionality for MongoDB Flex instance backups
43+
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
## stackit mongodbflex backup update-schedule
2+
3+
Updates the backup schedule and retention policy for a MongoDB Flex instance
4+
5+
### Synopsis
6+
7+
Updates the backup schedule and retention policy for a MongoDB Flex instance.
8+
The current backup schedule and retention policy can be seen in the output of the "stackit mongodbflex backup schedule" command.
9+
The backup schedule is defined in the cron scheduling system format e.g. '0 0 * * *'.
10+
See below for more detail on the retention policy options.
11+
12+
```
13+
stackit mongodbflex backup update-schedule [flags]
14+
```
15+
16+
### Examples
17+
18+
```
19+
Update the backup schedule of a MongoDB Flex instance with ID "xxx"
20+
$ stackit mongodbflex backup update-schedule --instance-id xxx --schedule '6 6 * * *'
21+
22+
Update the retention days for snapshots of a MongoDB Flex instance with ID "xxx" to 5 days
23+
$ stackit mongodbflex backup update-schedule --instance-id xxx --save-snapshot-days 5
24+
```
25+
26+
### Options
27+
28+
```
29+
-h, --help Help for "stackit mongodbflex backup update-schedule"
30+
--instance-id string Instance ID
31+
--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.
32+
--save-monthly-snapshot-months int Number of months to retain monthly snapshots
33+
--save-snapshot-days int Number of days to retain snapshots. Should be less than or equal to the value of the daily backup.
34+
--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.
35+
--schedule string Backup schedule, in the cron scheduling system format e.g. '0 0 * * *'
36+
```
37+
38+
### Options inherited from parent commands
39+
40+
```
41+
-y, --assume-yes If set, skips all confirmation prompts
42+
--async If set, runs the command asynchronously
43+
-o, --output-format string Output format, one of ["json" "pretty" "none"]
44+
-p, --project-id string Project ID
45+
--verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info")
46+
```
47+
48+
### SEE ALSO
49+
50+
* [stackit mongodbflex backup](./stackit_mongodbflex_backup.md) - Provides functionality for MongoDB Flex instance backups
51+

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ require (
1717
github.com/stackitcloud/stackit-sdk-go/core v0.12.0
1818
github.com/stackitcloud/stackit-sdk-go/services/authorization v0.2.0
1919
github.com/stackitcloud/stackit-sdk-go/services/dns v0.9.1
20-
github.com/stackitcloud/stackit-sdk-go/services/mongodbflex v0.12.0
20+
github.com/stackitcloud/stackit-sdk-go/services/mongodbflex v0.13.0
2121
github.com/stackitcloud/stackit-sdk-go/services/opensearch v0.14.0
2222
github.com/stackitcloud/stackit-sdk-go/services/postgresflex v0.13.0
2323
github.com/stackitcloud/stackit-sdk-go/services/resourcemanager v0.8.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ github.com/stackitcloud/stackit-sdk-go/services/logme v0.14.0 h1:vvQFCN5sKZA9tdz
103103
github.com/stackitcloud/stackit-sdk-go/services/logme v0.14.0/go.mod h1:bj9cn1treNSxKTRCEmESwqfENN8vCYn60HUnEA0P83c=
104104
github.com/stackitcloud/stackit-sdk-go/services/mariadb v0.14.0 h1:tK6imWrbZ5TgQJbukWCUz7yDgcvvFMX8wamxkPTLuDo=
105105
github.com/stackitcloud/stackit-sdk-go/services/mariadb v0.14.0/go.mod h1:kPetkX9hNm9HkRyiKQL/tlgdi8frZdMP8afg0mEvQ9s=
106-
github.com/stackitcloud/stackit-sdk-go/services/mongodbflex v0.12.0 h1:/m6N/CdsFxomexsowU7PwT1S4UTmI39PnEvvWGsDh1s=
107-
github.com/stackitcloud/stackit-sdk-go/services/mongodbflex v0.12.0/go.mod h1:iFerEzGmkg6R13ldFUyHUWHm0ac9cS4ftTDLhP0k/dU=
106+
github.com/stackitcloud/stackit-sdk-go/services/mongodbflex v0.13.0 h1:Dhanx9aV5VRfpHg22Li07661FbRT5FR9/M6FowN08a8=
107+
github.com/stackitcloud/stackit-sdk-go/services/mongodbflex v0.13.0/go.mod h1:iFerEzGmkg6R13ldFUyHUWHm0ac9cS4ftTDLhP0k/dU=
108108
github.com/stackitcloud/stackit-sdk-go/services/objectstorage v0.9.0 h1:rWgy4/eCIgyA2dUuc4a30pldmS6taQDwiLqoeZmyeP8=
109109
github.com/stackitcloud/stackit-sdk-go/services/objectstorage v0.9.0/go.mod h1:dkVMJI88eJ3Xs0ZV15r4tUpgitUGJXcvrX3RL4Zq2bQ=
110110
github.com/stackitcloud/stackit-sdk-go/services/opensearch v0.14.0 h1:zkhm0r0OZ5NbHJFrm+7B+h11QL0bNLC53nzXhqCaLWo=

internal/cmd/mongodbflex/backup/backup.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ package backup
33
import (
44
"github.com/stackitcloud/stackit-cli/internal/cmd/mongodbflex/backup/describe"
55
"github.com/stackitcloud/stackit-cli/internal/cmd/mongodbflex/backup/list"
6+
"github.com/stackitcloud/stackit-cli/internal/cmd/mongodbflex/backup/restore"
67
restorejobs "github.com/stackitcloud/stackit-cli/internal/cmd/mongodbflex/backup/restore-jobs"
8+
"github.com/stackitcloud/stackit-cli/internal/cmd/mongodbflex/backup/schedule"
9+
updateschedule "github.com/stackitcloud/stackit-cli/internal/cmd/mongodbflex/backup/update-schedule"
710
"github.com/stackitcloud/stackit-cli/internal/pkg/args"
811
"github.com/stackitcloud/stackit-cli/internal/pkg/print"
912
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
@@ -24,6 +27,9 @@ func NewCmd(p *print.Printer) *cobra.Command {
2427
}
2528

2629
func addSubcommands(cmd *cobra.Command, p *print.Printer) {
30+
cmd.AddCommand(updateschedule.NewCmd(p))
31+
cmd.AddCommand(schedule.NewCmd(p))
32+
cmd.AddCommand(restore.NewCmd(p))
2733
cmd.AddCommand(list.NewCmd(p))
2834
cmd.AddCommand(describe.NewCmd(p))
2935
cmd.AddCommand(restorejobs.NewCmd(p))

0 commit comments

Comments
 (0)