Skip to content

feat(pitr): add command to restore a database to a specific point in time - #1244

Merged
matthieu526-scalingo merged 8 commits into
masterfrom
feat/sTORY-3565/create-pitr-restore-command
Aug 11, 2026
Merged

feat(pitr): add command to restore a database to a specific point in time#1244
matthieu526-scalingo merged 8 commits into
masterfrom
feat/sTORY-3565/create-pitr-restore-command

Conversation

@matthieu526-scalingo

@matthieu526-scalingo matthieu526-scalingo commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Add a new command to restore PITR.
It reuses the same mechanism as maintenance. Both components are shared between SR addons and DR databases.
It adds a small check to ensure the time is correctly parsed.

  • Add a changelog entry in the section "To Be Released" of CHANGELOG.md
  • right now depending on this PR. Before merging it should be set to a released version (or not?)
  • QA not executed yet
    • Working as expected, restoration is triggered

@matthieu526-scalingo matthieu526-scalingo self-assigned this Aug 5, 2026
@matthieu526-scalingo
matthieu526-scalingo requested a review from a team as a code owner August 5, 2026 14:09
@matthieu526-scalingo
matthieu526-scalingo requested review from SCedricThomas, briceamen and curzolapierre and removed request for a team and briceamen August 5, 2026 14:09
@matthieu526-scalingo
matthieu526-scalingo marked this pull request as draft August 5, 2026 14:10

@curzolapierre curzolapierre left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a question otherwise LGTM

Comment thread db/pitr/restore.go Outdated
return errors.Wrapf(ctx, err, "get Scalingo client")
}

operationID, err := c.DatabasePITRRestore(ctx, currentResource, addonName, restoreTime)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: what about adding a confirmation message to the end user?
Which would format the date as human readable (maybe add the local time conversion).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean? There is a io.Status 2 lines below. Or do you mean improving said message?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry it was not clear: I had in mind something like apps destroy command, ask for an user confirmation before to proceed the operation:

fmt.Printf("/!\\ You're going to delete %s, this operation is irreversible.\nTo confirm type the name of the application: ", appName)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question! Usually I'd have asked Benjamin, or checked how it is in the dashboard. But you are right, as it is a destructive action it might be better.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added here fc07c8c. I added a yes/no more than a name, as the use can use the addon name or ID or type, it didn't see great.

Comment thread README.md

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Praise thanks for this update

Comment thread db/pitr/restore.go Outdated
return errors.Wrap(ctx, err, "restore database")
}

io.Statusf("Database restore operation %s has been created", operationID)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: what does the output looks like?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure what you mean? It will just display a line with that info, like we do on many other commands (eg project creation)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am asking because there is no "\n" at the end. Usually I would expect a newline at the end

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oooooh. I see what you mean, nice catch 🙇 . I guess the example I used was wrong.
I haven't QAed yet (as stated in the description)

@matthieu526-scalingo
matthieu526-scalingo marked this pull request as ready for review August 10, 2026 10:30
@matthieu526-scalingo
matthieu526-scalingo force-pushed the feat/sTORY-3565/create-pitr-restore-command branch from fc07c8c to 1f69aa8 Compare August 11, 2026 10:18

@SCedricThomas SCedricThomas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just a reminder. Ping me when you need a reapproval post release

Comment thread go.mod Outdated
require (
github.com/AlecAivazis/survey/v2 v2.3.7
github.com/Scalingo/go-scalingo/v11 v11.1.1
github.com/Scalingo/go-scalingo/v11 v11.1.2-0.20260810154739-f30bd2e7ef2c

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reminder: don't forget to release v11.1.2 before merging this PR

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(:information_source: discussion about that here)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@matthieu526-scalingo
matthieu526-scalingo merged commit f449b89 into master Aug 11, 2026
6 checks passed
@matthieu526-scalingo
matthieu526-scalingo deleted the feat/sTORY-3565/create-pitr-restore-command branch August 11, 2026 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants