Back up your Aiven for MySQL® service to another region
Copy your Aiven for MySQL® service backups to a secondary region for disaster recovery.
In addition to the primary service backup, you can have a secondary backup in an alternative location.
This feature is in limited availability. Contact your account team to enable it.
Backup to another region (BTAR) is a disaster recovery feature that allows backup files to be copied from the service's primary backup region to an additional (secondary) region. BTAR can bolster data resilience and helps improve data protection against disasters in the primary backup region. When the primary region is down, BTAR allows forking the service from an additional copy of the backup residing in a secondary region.
Limitations
- The cloud provider for your additional backup region must match the cloud provider for your service and the primary backup.
- Secondary backup can only be restored in the region where it was stored.
For a service that has the backup to another region (BTAR) feature enabled, you can check the service backup status, change the backup region, monitor the replication lag, fork and restore using the cross-region backup, or migrate to another cloud or region.
Prerequisites
- At least one Aiven service with BTAR enabled
- Access to the Aiven Console
- Aiven API
- Aiven CLI
Change a backup region
- Log in to the Aiven Console and go to your project.
- On the Services page, select an Aiven service on which you'd like to enable BTAR.
- On your service page, click Backups in the sidebar.
- On the Backups page, click Actions > Edit secondary backup location.
- In the Edit secondary backup location window, use the Backup location menu to select a region for your additional backup. Confirm your choice by selecting Save.
You can change the backup region once in 24 hours.
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
To see the availability, the status, and the target region of a secondary (BTAR) backup in the Aiven Console, go to your service page > Backups > Secondary backup location.
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
You can use the Aiven Console, API, or CLI to recover your service from a backup in another region. To restore your service using BTAR, create a fork of the original service in the region where the secondary backup resides.
When you fork & 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
-
Open the Aiven Console and go to your service homepage.
-
Click Backups in the sidebar.
-
On the Backups page, select Fork & restore.
-
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
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.
You can delete a cross-region backup using the Aiven Console, API, or CLI. 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
- 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, select Backups from the sidebar.
- On the Backups page, click Actions > Secondary backup location.
- In the Edit secondary backup location window, select Disable.
Your additional service backup is no longer visible on your service's Backups page in the Secondary backup location column.
To remove secondary backups for your service, use the
avn service update command to remove all target region names
from the additional_backup_regions array.
avn service update your-sevice-name \
-c additional_backup_regions=\[\]
To remove secondary backups for your service, update the service configuration. Use the
ServiceUpdate endpoint
to remove all target regions names from the additional_backup_regions array.
curl --request PUT \
--url https://api.aiven.io/v1/project/YOUR_PROJECT_NAME/service/YOUR_SERVICE_NAME \
--header 'Authorization: Bearer YOUR_BEARER_TOKEN' \
--header 'content-type: application/json' \
--data
'{
"user_config": {
"additional_backup_regions": []
}
}'
Related pages