Add `atlas backups restores watch` command
I like the ability to monitor snapshot progress with atlas snapshot watch
. It lets me wait for the snapshot to finish up before progressing on to some future step of an automated workflow.
Could we add the same watch command to atlas backup restore? The API I'm envisioning is just this:
atlas backups restores watch <restoreId> [options]
Where [options]
are all the usual suspects like --projectId
--profile
and so forth. Like the snapshots watch
command, this will help me wait for a database to finish restoring some snapshot before going and doing some other step of an automated workflow.
There's a workaround, but it's a pretty tedious process:
Page through the full history of restores with
atlas backups restores list
until I find the page and results index of the most recent restore of the desired snapshot + cluster combo.Poll for the status of that result until
--output json-path='$.results[n].finishedAt'
returns a date instead of an errorFetch the
--output json-path='$.results[<idx of the right result>].failed'
of that result and checking if it'strue
orfalse
to identify if we continue with other work or not.
Thank you again for all your feedback and engagement in making the Atlas CLI more usable for you and other customers.
As per my colleagues earlier comment: this capability was delivered in Atlas 1.2.0 release and you can view the changelog here: https://www.mongodb.com/docs/atlas/cli/stable/atlas-cli-changelog/#atlas-cli-v1.2.0
We appreciate all your insights so please keep them coming.
Thank you,
Jakub
-
Gustavo commented
This command is now available since 1.2.0
-
AdminJakub (Admin, MongoDB) commented
Thank you for taking the time to file this request, comment and vote. Your feedback helps us make the Atlas CLI a better place for you and other users. At the same time I’d like to apologise for the late reply.
We believe that all long-running / asynchronous actions should have the respective “watch” command. We’ll be adding them gradually to the Atlas CLI as we see needs amongst customers. Therefore filing ideas like this helps!
Having said that, “atlas backups restores watch” is on our mid-term roadmap. We’ll update this idea as soon as we have more details on the timelines.In meantime, what other actions do you believe should have the “watch” command available?
Keep the ideas coming!
Jakub -
Isaac Lee commented
I personally couldn't get the workaround to work, and ended up having to resort to `curl`. If this is your situation, and you end up switching from CLI to hybrid-CLI/API, I found this part confusing: `user:password` in their API documentation refers to your public and private Atlas API key. Hopefully that helps.
-
Esteban Pedro Aramendi Terpin commented
Same.
I wanted to make a similar process and found that I could not get the current process of the restore job.Would be great to have a similar command as atlas snapshot watch for the restore process.
-
Isaac Lee commented
The workaround I came up with also won't work one or more snapshot restores start before you get to the end of step 3. For that, you actually have to validate that the restore ID at the page and index you're looking at hasn't changed. If it does change, you have to page through the results again, and find your job again.
That said, the docs don't call out any guaranteed ordering of the results.
If this is your use-case, you're probably better off doing a polling `curl` of the "self" link of the restore job once you find the ID by paging through all the results.
-
Isaac Lee commented
I have a couple small typos, but it looks like the edit button is broken, so I can't fix it.