Back up your Aiven for OpenSearch® service to another region
Copy your Aiven for OpenSearch® service backups to a secondary region for disaster recovery.
In addition to the primary service backup, you can keep a secondary backup in another region.
Backup to another region (BTAR) is a disaster recovery feature that copies backup files from your service's primary backup region to an additional, secondary region. BTAR improves data resilience and protects your data against an outage in the primary backup region. If the primary region becomes unavailable, you can fork your service from the backup copy stored in the secondary region.
BTAR is not a live replica of your database. It replicates backup files asynchronously, so recovery means forking or restoring from those files rather than failing over to a running standby. For a live standby with managed failover, use cross-region disaster recovery on Aiven for PostgreSQL® instead.
Charges
BTAR is charged based on your usage, with no flat fee. Charges cover the following:
- Secondary backup storage: Aiven charges for each GB-month of backup data stored in the secondary region, based on the logical size of each retained backup. Each retained backup is charged separately, so a longer backup retention increases the stored data you pay for. The rate depends on the secondary backup region.
- Cross-region backup transfer: Aiven charges for the backup data copied from the primary region to the secondary region, for each GB. The rate depends on whether the two regions are on the same continent.
Secondary backup storage is charged for as long as the backups are retained in the secondary region, including while your service is powered off. Powering off a service stops backup transfer charges, because the service creates no new backups, but storage charges continue.
Restoring from a secondary backup adds no transfer charge, because the restore runs in the region where the backup is stored.
For bring your own cloud services, Aiven charges a flat monthly fee for each service with BTAR enabled. You pay your cloud provider directly for the storage and transfer.
Limitations
- The cloud provider for your secondary backup region must match the cloud provider for your service and its primary backup.
- You can configure one secondary backup region for each service.
- BTAR is available only on the Professional service tier. To change your service to a plan outside the Professional service tier, remove the secondary backup region first.
- For bring your own cloud services, the secondary backup region must be one of your custom cloud regions.
- You can restore a secondary backup only in the region where it is stored.
- To fork from a secondary backup, the backup must already be replicated to the secondary region.
- Read replicas cannot restore from a secondary backup.
With backup to another region (BTAR), you can add or change a secondary backup region, check the secondary backup status, monitor the replication lag, fork and restore using the cross-region backup, or migrate to another cloud or region.
BTAR is configured with the additional_backup_regions option in your service
configuration. The option takes one region, which holds the secondary backup for your
service.
Prerequisites
- At least one Aiven service that supports BTAR
- One of the following: the Aiven Console, the Aiven CLI, the Aiven API, the Aiven Provider for Terraform, or the Aiven Operator for Kubernetes®
Add a secondary backup region
- Aiven Console
- Aiven CLI
- Aiven API
- Terraform
- Kubernetes
- Log in to the Aiven Console and go to your project.
- Go to Services, then select the Aiven service on which you'd like to enable BTAR.
- On your service page, in the Backups section, click Backup management.
- On the Backups page, click Actions > Add secondary backup location.
- In the Add secondary backup region window, turn on Secondary backup location enabled.
- Use the Backup location menu to select a region for your secondary backup.
- Review the Additional costs card with the rates for the selected region.
- Click Add backup region.
Use the avn service update command to set
additional_backup_regions to the region you want to hold the secondary backup.
avn service update SERVICE_NAME \
--project PROJECT_NAME \
-c additional_backup_regions='["SECONDARY_REGION"]'
Replace the following:
SERVICE_NAME: the name of your servicePROJECT_NAME: the name of your projectSECONDARY_REGION: the cloud and region to hold the secondary backup, for exampleaws-us-east-2
Use the ServiceUpdate
endpoint to set additional_backup_regions in the service configuration.
curl --request PUT \
--url https://api.aiven.io/v1/project/PROJECT_NAME/service/SERVICE_NAME \
--header 'Authorization: Bearer BEARER_TOKEN' \
--header 'content-type: application/json' \
--data '{"user_config": {"additional_backup_regions": ["SECONDARY_REGION"]}}'
Replace the following:
PROJECT_NAME: the name of your projectSERVICE_NAME: the name of your serviceBEARER_TOKEN: your authentication tokenSECONDARY_REGION: the cloud and region to hold the secondary backup, for exampleaws-us-east-2
Set additional_backup_regions in the service's user configuration block. The example
uses Aiven for PostgreSQL®; for Aiven for OpenSearch®, use aiven_opensearch and
opensearch_user_config.
resource "aiven_pg" "example" {
project = var.project_name
service_name = "example-service"
cloud_name = "google-europe-west1"
plan = "business-4"
pg_user_config {
additional_backup_regions = ["google-europe-north1"]
}
}
Set additional_backup_regions under spec.userConfig. The example uses the PostgreSQL
kind; for Aiven for OpenSearch®, use the OpenSearch kind.
apiVersion: aiven.io/v1alpha1
kind: PostgreSQL
metadata:
name: example-service
spec:
project: PROJECT_NAME
cloudName: google-europe-west1
plan: business-4
userConfig:
additional_backup_regions:
- google-europe-north1
Aiven provisions storage in the region you selected and starts replicating backup files to it. Until the first backup finishes replicating, you cannot fork your service from the secondary backup.
Change a secondary backup region
Repeat Add a secondary backup region and select a different region. In the Aiven Console, the action is called Edit secondary backup location once the service already has a secondary location. To apply the new region, click Save backup region.
Changing the secondary backup region starts a new base backup. You can fork your service from the new region only after that backup finishes.
Monitor a service with BTAR
There are a few things you may want to check for your Aiven service in the context of BTAR:
-
What is the status of a secondary backup?
- Does your service have a backup in another region?
- What is the target region of the secondary backup?
-
What is the replication lag between data availability in the primary region and the secondary region?
Check BTAR status
- Aiven Console
- Aiven CLI
- Aiven API
- Terraform
- Kubernetes
To see the availability, the status, and the target region of a secondary (BTAR) backup, go to your service page > Backups > Secondary backup location.
Run avn service get and read
user_config.additional_backup_regions. The field contains the region that holds the
secondary backup. If the service has no secondary backup, the field is not set.
avn service get SERVICE_NAME --project PROJECT_NAME --json
Call the ServiceGet endpoint
and read user_config.additional_backup_regions in the response. The field contains the
region that holds the secondary backup. If the service has no secondary backup, the field
is not set.
curl --request GET \
--url https://api.aiven.io/v1/project/PROJECT_NAME/service/SERVICE_NAME \
--header 'Authorization: Bearer BEARER_TOKEN'
Read the attribute from the Terraform state.
terraform state show aiven_pg.example
Read the field from the service manifest.
kubectl get postgresql example-service \
-o jsonpath='{.spec.userConfig.additional_backup_regions}'
Determine replication lag
Determine the target region and the replication lag for a secondary (BTAR) backup of your service, call the ServiceBackupToAnotherRegionReport endpoint.
Configure the call as follows:
- Enter
YOUR-PROJECT-NAMEandYOUR-SERVICE-NAMEinto the URL. - Specify
DESIRED-TIME-PERIODdepending on the time period you need the metrics for: select one of the following values for theperiodkey:hour,day,week,month, oryear.
curl --request POST \
--url https://api.aiven.io/v1/project/YOUR-PROJECT-NAME/service/YOUR-SERVICE-NAME/backup_to_another_region/report \
--header 'Authorization: Bearer YOUR-BEARER-TOKEN' \
--header 'content-type: application/json' \
--data '{"period":"DESIRED-TIME-PERIOD"}'
As output, you get metrics including replication lags at specific points in time.
Fork and restore a service with BTAR
To restore your service using BTAR, create a fork of the original service in the region where the secondary backup resides.
When you fork and restore from the secondary backup, your new fork service is created in the cloud and region where the secondary backup is located. The fork service gets the same plan that the primary service uses. Backups of the fork service are located in the region where this new service is hosted.
- Aiven Console
- Aiven CLI
- Aiven API
- Terraform
- Kubernetes
-
Open the Aiven Console and go to your service homepage.
-
Click Backups.
-
On the Backups page, click Fork service.
-
In the New database fork window:
-
Set Backup location to either Primary location or Secondary location.
-
Set Backup version to one of the following:
- Latest transaction
- Point in time: Set it up to no earlier than the time of taking the oldest replicated base backup.
-
Specify a name for the new fork service.
-
Select Create fork.
-
Run the avn service create command
with the --service-to-fork-from option and the --recovery-target-timeoption. Set
--recovery-target-time to no earlier than the time of taking the oldest replicated base
backup.
avn service create FORK_SERVICE_NAME \
--plan SERVICE_PLAN \
--project PROJECT_NAME \
--service-type SERVICE_TYPE \
--cloud SECONDARY_BACKUP_REGION \
--recovery-target-time "YYYY-MM-DDTHH:MM:SS+00:00" \
--service-to-fork-from PRIMARY_SERVICE_NAME
Replace the following with meaningful data:
FORK_SERVICE_NAMESERVICE_PLANPROJECT_NAMESERVICE_TYPESECONDARY_BACKUP_REGIONPRIMARY_SERVICE_NAMEYYYY-MM-DDTHH:MM:SS+00:00
Use the ServiceCreate API
to create a fork service. When constructing the API request, add the user_config object
to the request body and nest the service_to_fork_from field and the
recovery_target_time field inside. Set recovery_target_time to no earlier than the
time of taking the oldest replicated base backup.
curl --request POST \
--url https://api.aiven.io/v1/project/PROJECT_NAME/service \
--header 'Authorization: Bearer BEARER_TOKEN' \
--header 'content-type: application/json' \
--data
'{
"cloud": "SECONDARY_BACKUP_REGION",
"plan": "SERVICE_PLAN",
"service_name": "FORK_SERVICE_NAME",
"service_type": "SERVICE_TYPE",
"user_config": {
"service_to_fork_from": "PRIMARY_SERVICE_NAME",
"recovery_target_time": "YYYY-MM-DDTHH:MM:SS+00:00"
}
}'
Replace the following with meaningful data:
FORK_SERVICE_NAMESERVICE_PLANPROJECT_NAMESERVICE_TYPESECONDARY_BACKUP_REGIONPRIMARY_SERVICE_NAMEYYYY-MM-DDTHH:MM:SS+00:00
Create a new service in the secondary backup region, with service_to_fork_from and
recovery_target_time set in its user configuration block. Set recovery_target_time to
no earlier than the time of taking the oldest replicated base backup. The example uses
Aiven for PostgreSQL®; for Aiven for OpenSearch®, use aiven_opensearch and
opensearch_user_config.
resource "aiven_pg" "fork" {
project = var.project_name
service_name = "example-fork"
cloud_name = "google-europe-north1"
plan = "business-4"
pg_user_config {
service_to_fork_from = "example-service"
recovery_target_time = "2026-11-04T10:00:00+00:00"
}
}
Create a new service in the secondary backup region, with service_to_fork_from and
recovery_target_time set under spec.userConfig. Set recovery_target_time to no
earlier than the time of taking the oldest replicated base backup. The example uses the
PostgreSQL kind; for Aiven for OpenSearch®, use the OpenSearch kind.
apiVersion: aiven.io/v1alpha1
kind: PostgreSQL
metadata:
name: example-fork
spec:
project: PROJECT_NAME
cloudName: google-europe-north1
plan: business-4
userConfig:
service_to_fork_from: example-service
recovery_target_time: "2026-11-04T10:00:00+00:00"
Migrate a service with BTAR
You can migrate a service with BTAR the same way you migrate a service with a regular backup.
When you migrate your service, locations of service backups, both primary and secondary ones, do not change.
Delete a cross-region backup
Delete an additional service backup created in a region different from your primary backup region. When you delete the additional cross-region backup, you still have the default backup located in the primary, service-hosting region.
- Aiven Console
- Aiven CLI
- Aiven API
- Terraform
- Kubernetes
- Log in to the Aiven Console.
- From the Services view, select an Aiven service on which you'd like to disable BTAR.
- On your service's page, in the Backups section, click Backup management.
- On the Backups page, click Actions > Edit secondary backup location.
- In the Edit secondary backup region window, turn off Secondary backup location enabled.
- Click Save.
Your additional service backup is no longer visible on your service's Backups page in the Secondary backup location column.
To remove the secondary backup for your service, use the
avn service update command to remove the target region from
the additional_backup_regions array.
avn service update SERVICE_NAME \
--project PROJECT_NAME \
-c additional_backup_regions='[]'
To remove the secondary backup for your service, update the service configuration. Use
the ServiceUpdate
endpoint to remove the target region from the additional_backup_regions array.
curl --request PUT \
--url https://api.aiven.io/v1/project/PROJECT_NAME/service/SERVICE_NAME \
--header 'Authorization: Bearer BEARER_TOKEN' \
--header 'content-type: application/json' \
--data '{"user_config": {"additional_backup_regions": []}}'
Set additional_backup_regions to an empty list, then apply the change.
pg_user_config {
additional_backup_regions = []
}
Set additional_backup_regions to an empty list, then apply the manifest.
spec:
userConfig:
additional_backup_regions: []
Related pages