Skip to content
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

google_sql_database_instance PITR restore action #6848

Closed
ghost opened this issue Jul 23, 2020 · 9 comments · Fixed by GoogleCloudPlatform/magic-modules#4431, hashicorp/terraform-provider-google-beta#2923 or #8367

Comments

@ghost
Copy link

ghost commented Jul 23, 2020

This issue was originally opened by @doriandekoning as hashicorp/terraform#25660. It was migrated here as a result of the provider split. The original body of the issue is below.


Current Terraform Version

v0.12.28

Use-cases

Create an gcloud instance clone from a specific point in time of another instance.

Attempted Solutions

Click some buttons in the gcloud dashboard to restore a PiT

Proposal

Support enabling pointInTimeRecoveryEnabled for an sql cloud instance together with an argument that supports setting the instance from which a point in time should be restored and which point in time should be restored. An illustration:

pitr_restore_from = {
  time = <timestamp>
  instance = <instance>
}

References

https://cloud.google.com/sql/docs/postgres/backup-recovery/pitr

If a decision is made on the arguments (and a merge request would be appreciated) I could take a shot at implementing this myself.

@doriandekoning
Copy link

doriandekoning commented Jul 23, 2020

Duplicate of #6774

@robertvanhoesel
Copy link

@doriandekoning This suggestion is different in that it proposes a way to create a new Database Instance using pitr rather that the enabling pitr through configuration.

@doriandekoning
Copy link

Oh my bad, you're right! I thought that was what the start_time parameter was to be able to do that, but seems to be to specify when to start backing up?

@danawillow
Copy link
Contributor

@doriandekoning you're welcome to give this a try! Depending on what sorts of things you see when you implement it, you may end up needing to do it as a separate resource. We can give you more help once you send out the PR for review.

@nat-henderson
Copy link
Contributor

If you need some help while working on this, I'm happy to consult - post here if you need anything. :)

@doriandekoning
Copy link

@danawillow @ndmckinley
Thanks for your replies! I've looked into making it a separate resource but I think this will cause some strange behaviour when importing instances. for example. Because afaik there is no way to distinguish a clone from a "real" instance after creation. I've taken a shot at this which can be seen here: #6862
This is far from finished (lacking proper tests for example), but this was all the time I had tonight, but I think the general idea should be clear?

Could you take a quick look at it and let me know what you think? If I'm in the right direction, I'll finish it up later this week.

@rileykarson rileykarson changed the title Gcloud cloudsql postgres point in time support google_sql_database_instance PITR support in google_sql_database_instance Oct 9, 2020
@rileykarson rileykarson removed this from the Backlog milestone Oct 9, 2020
@danawillow danawillow added this to the Near-Term Goals milestone Oct 12, 2020
@rileykarson
Copy link
Collaborator

Tracked internally as b/170484123

@rileykarson rileykarson changed the title PITR support in google_sql_database_instance google_sql_database_instance PITR restore action Oct 12, 2020
@rileykarson
Copy link
Collaborator

This is done using the https://cloud.google.com/sql/docs/mysql/admin-api/rest/v1beta4/instances/clone endpoint, an alternative create endpoint.

It's unclear how the SQL settings are applied when cloning- we'd likely need to call into Update, which also won't work if HasChange is used.

@rileykarson rileykarson modified the milestones: Near-Term Goals, Sprint 25 Nov 9, 2020
@rileykarson rileykarson modified the milestones: Sprint 25, Sprint 26 Nov 23, 2020
@rileykarson rileykarson removed this from the Sprint 26 milestone Dec 7, 2020
@ghost
Copy link
Author

ghost commented Mar 5, 2021

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

@ghost ghost locked as resolved and limited conversation to collaborators Mar 5, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.