Perform Aiven for PostgreSQL® switchback to the primary region Limited availability
Shift your workloads back to the primary region, where your service was hosted originally before switching over to the recovery region.
Prerequisites
- CRDR switchover completed
- One of the following tools for operating CRDR:
Switch back
- CLI
- API
- Terraform
Use the Aiven CLI to perform a switchback:
avn service disaster-recovery promote-to-master \
--project PROJECT_NAME \
SERVICE_NAME
Replace the placeholders with your actual values:
PROJECT_NAME
: Your Aiven project nameSERVICE_NAME
: Name of your primary PostgreSQL service
Monitor the switchback status:
avn service disaster-recovery get \
--project PROJECT_NAME \
SERVICE_NAME
Use the ServiceUpdate API endpoint to perform a switchback:
curl -X PUT \
"https://api.aiven.io/v1/project/PROJECT_NAME/service/SERVICE_NAME" \
-H "Authorization: Bearer API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"disaster_recovery_promote_to_master": true
}'
Replace the placeholders:
PROJECT_NAME
: Your Aiven project nameSERVICE_NAME
: Name of your primary PostgreSQL serviceAPI_TOKEN
: Your Aiven API authentication token
Check the disaster recovery status:
curl -X GET \
"https://api.aiven.io/v1/project/PROJECT_NAME/service/SERVICE_NAME/disaster-recovery" \
-H "Authorization: Bearer API_TOKEN"
The
aiven_service_integration
resource with the disaster_recovery
type manages the active-passive relationship between
services. CRDR operations are performed by manipulating this integration.
To return to the original primary-recovery configuration after a planned switchover:
-
Comment out or remove the current switched disaster recovery integration.
# resource "aiven_service_integration" "disaster_recovery_switched" {
# project = var.project_name
# integration_type = "disaster_recovery"
# source_service_name = aiven_postgresql.recovery.service_name
# destination_service_name = aiven_postgresql.primary.service_name
# }or
terraform destroy -target=aiven_service_integration.disaster_recovery_switched
-
Restore the original CRDR configuration.
resource "aiven_service_integration" "disaster_recovery" {
project = var.project_name
integration_type = "disaster_recovery"
source_service_name = aiven_postgresql.primary.service_name # Back to original active
destination_service_name = aiven_postgresql.recovery.service_name # Back to original passive
depends_on = [
aiven_postgresql.primary,
aiven_postgresql.recovery
]
} -
Wait for the switchback to complete before restoring the original setup.
terraform apply
-
Verify the switchback has been completed successfully.
terraform refresh
terraform show aiven_service_integration.disaster_recovery
When the switchback process is completed, your primary service is Active, and the recovery service is Passive, which means the primary service is in control over your workloads.
Related pages