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

Restoring Azure PostgreSQL Flexible Server in the Same Region Using Point-in-Time Restore with Terraform #125067

Open
VinaykumarBolli1 opened this issue Dec 5, 2024 · 2 comments

Comments

@VinaykumarBolli1
Copy link

VinaykumarBolli1 commented Dec 5, 2024

Documentation Reference: AzureRM Terraform Provider: PostgreSQL Flexible Server
Azure REST API: Create PostgreSQL Flexible Server
Point-in-Time Restore for Azure SQL Managed Instances

Overview: This guide provides a step-by-step explanation for performing a restore operation of an Azure PostgreSQL Flexible Server in the same region using Terraform. The correct method for restoring in the same region is using a "Point-in-Time Restore," whereas "GeoRestore" is used for restoring in a different region.

The point-in-time restore feature enables users to recover data from a specific point in time, which can help restore servers to a state prior to unexpected incidents or errors.

Correction Details:

This guide outlines:

The differences between using "GeoRestore" and "Point-in-Time Restore."
How to configure the Azure PostgreSQL Flexible Server for a same-region restore.
Steps for properly setting up create_mode to achieve a point-in-time restore in the same region.
Steps

Prerequisites:

Create an Azure Resource Group and an initial Azure PostgreSQL Flexible Server.
Ensure a backup is available for the server that can be used for restoration.
Steps to Restore PostgreSQL Flexible Server in the Same Region

Configure the Resource for Point-in-Time Restore
To perform a restore in the same region, use create_mode = "PointInTimeRestore":

resource "azurerm_postgresql_flexible_server" "restored_server" {
  depends_on             = [time_sleep.wait_before_restore]
  name                   = "sameregionrestoreserver"
  location               = azurerm_resource_group.example.location
  resource_group_name    = azurerm_resource_group.example.name
  storage_mb             = 131072
  sku_name               = "GP_Standard_D2ds_v4"
  backup_retention_days  = 7
  geo_redundant_backup_enabled = true
  create_mode            = "PointInTimeRestore"
  source_server_id       = azurerm_postgresql_flexible_server.new_server.id
  point_in_time_restore_time_in_utc = "2024-11-06T13:15:21.000Z"
}

In this configuration:
create_mode is set to "PointInTimeRestore" for same-region restoration.
source_server_id specifies the ID of the server from which the point-in-time restore will be performed.
point_in_time_restore_time_in_utc allows specifying the exact point in time to restore from, ensuring precise control over the restoration.
Explanation:

Using "GeoRestore" is intended for restoring the server in a different region, which is not suitable for same-region restores.
For restoring within the same region, "PointInTimeRestore" should be used as it allows specifying a specific timestamp for restoring the database.
Deployment Example

This example configuration ensures that the PostgreSQL Flexible Server can be restored to a specific point in time, providing high reliability in disaster recovery scenarios within the same region.

Conclusion

By following this guide, users can:

Use "PointInTimeRestore" to restore Azure PostgreSQL Flexible Servers in the same region effectively.
Avoid misconfiguration that could lead to unexpected failures by understanding the intended use of "GeoRestore" and "PointInTimeRestore".
Best Practices:

Always verify the correct usage of create_mode depending on whether you need a cross-region restore or a point-in-time restore.
Ensure that the backup retention policy is configured to meet your organization's requirements for data recovery.
Refer to the following additional resources for more guidance:

AzureRM Terraform Provider: PostgreSQL Flexible Server
Azure REST API: Create PostgreSQL Flexible Server
Point-in-Time Restore for Azure SQL Managed Instances - This article provides more details on how point-in-time restores work for Azure services and can be applied to PostgreSQL Flexible Server scenarios.


title: Point-in-time restore
titleSuffix: Azure SQL Managed Instance
description: Learn how to restore a database to an earlier point in time for Azure SQL Managed Instance.
author: @Stralle
ms.author: @strrodic
ms.reviewer: @MaThoma, @nvraparl
ms.service: azure-sql-managed-instance
ms.subservice: backup-restore

@TPavanBalaji
Copy link
Contributor

@VinaykumarBolli1
Thanks for your feedback! We will investigate and update as appropriate.

@TPavanBalaji
Copy link
Contributor

TPavanBalaji commented Dec 9, 2024

@VinaykumarBolli1
Thank you for bringing this to our attention.
I've delegated this to content author, who will review it and offer their insightful opinions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants