We use terraform to manage our AWS RDS instances
The production database is setup to take daily backups and store them for 30 days
Find a snapshot identifier in the AWS Console and use it to restore an RDS instance in Terraform.
Snapshops have follow a convention starting with rds:-
A snapshop taken in January 1, 2023, might be rds:pg-medplum-2023-01-01-12-34-56
To create a new RDS instance from a snapshot, use the snapshot_identifier attribute in the aws_db_instance resource.
/terraform/aws/enviroment/prod/restore.tf
# Define the restored RDS instance
resource "aws_db_instance" "restored_example" {
engine = "mysql"
instance_class = "db.t3.micro"
allocated_storage = 20
storage_type = "gp2"
identifier = "restored-rds-instance"
username = "admin"
password = "password"
publicly_accessible = false
# Other RDS configuration settings...
# Specify the snapshot ID to restore from
snapshot_identifier = "<snapshot-id>"
}
Point the medplum application to the new RDS instance by updating the medplum
module in the main.tf
file and applying the terraform configuration