Skip to content

Commit

Permalink
pitr option added for btar setup
Browse files Browse the repository at this point in the history
  • Loading branch information
wojcik-dorota committed Feb 11, 2025
1 parent cc1177c commit 7f1588e
Show file tree
Hide file tree
Showing 3 changed files with 123 additions and 80 deletions.
27 changes: 15 additions & 12 deletions docs/platform/howto/btar/disable-backup-to-another-region.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,19 @@ limited: true
---

import ConsoleLabel from "@site/src/components/non-swizzled/ConsoleIcons";
import RelatedPages from "@site/src/components/non-swizzled/RelatedPages"
import RelatedPages from "@site/src/components/non-swizzled/RelatedPages";
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

Delete an [additional service backup](/docs/platform/concepts/backup-to-another-region) [created](/docs/platform/howto/btar/enable-backup-to-another-region) in a region different from your primary backup region.

You can delete a cross-region backup using the Aiven [console](#delete-btar-console),
[CLI](#delete-btar-cli), or [API](#delete-btar-api).

## Delete backup via console {#delete-btar-console}
You can delete a cross-region backup using the [Aiven Console](/docs/tools/aiven-console),
[API](/docs/tools/api), or [CLI](/docs/tools/cli). When you delete
the additional cross-region backup, you still have the default backup located in the
primary (service-hosting) region.

<Tabs groupId="group1">
<TabItem value="gui" label="Aiven Console" default>
1. Log in to the [Aiven Console](https://console.aiven.io/).
1. From the **Services** view, select an Aiven service on which you'd like to disable BTAR.
1. On your service's page, select **Backups** from the sidebar.
Expand All @@ -22,9 +26,8 @@ You can delete a cross-region backup using the Aiven [console](#delete-btar-cons

Your additional service backup is no longer visible on your service's **Backups** page in
the **Secondary backup location** column.

## Delete backup with CLI {#delete-btar-cli}

</TabItem>
<TabItem value="cli" label="Aiven CLI">
To remove secondary backups for your service, use the
[avn service update](/docs/tools/cli/service-cli) command to remove all target regions names
from the `additional_backup_regions` array.
Expand All @@ -34,8 +37,8 @@ avn service update your-sevice-name \
-c additional_backup_regions=\[\]
```

## Delete backup with API {#delete-btar-api}

</TabItem>
<TabItem value="api" label="Aiven API">
To remove secondary backups for your service, update the service configuration. Use the
[ServiceUpdate](https://api.aiven.io/doc/#tag/Service/operation/ServiceUpdate) endpoint
to remove all target regions names from the `additional_backup_regions` array.
Expand All @@ -53,8 +56,8 @@ curl --request PUT
}'
```

The additional cross-region backup has been deleted. You still have the default backup
located in the primary (service-hosting) region.
</TabItem>
</Tabs>

<RelatedPages/>

Expand Down
50 changes: 7 additions & 43 deletions docs/platform/howto/btar/enable-backup-to-another-region.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ BTAR is supported for Aiven for MySQL®, Aiven for PostgreSQL®, and Aiven for O
:::

To add an additional service backup for your service, you can use the Aiven Console, CLI,
or API.
or API. You can enable BTAR for

- [New Aiven service](/docs/platform/howto/btar/enable-backup-to-another-region#add-a-cross-region-backup-to-a-new-service)
or
- [Existing Aiven service](/docs/platform/howto/btar/enable-backup-to-another-region#add-a-cross-region-backup-to-an-existing-service)

## Prerequisites

Expand All @@ -27,8 +31,8 @@ or API.
- Depending on your preferred tool to manage BTAR with, make sure you can access or use:

- [Aiven Console](https://console.aiven.io/)
- [Aiven CLI client](/docs/tools/cli)
- [cURL](https://curl.se/download.html) CLI tool
- [Aiven CLI](/docs/tools/cli)
- [Aiven API](/docs/tools/api)

## Add a cross-region backup to an existing service

Expand All @@ -54,16 +58,6 @@ Your new additional backup is now visible on your service's **Backups** page in
**Secondary backup location** column.
</TabItem>
<TabItem value="cli" label="Aiven CLI">
Using the [Aiven CLI client](/docs/tools/cli), you can enable BTAR for

- [New Aiven service](#new-service-cli) or
- [Existing Aiven service](#existing-service-cli)

:::note[additional_backup_regions]
To enable BTAR on an Aiven service, add the `additional_backup_regions`
parameter to relevant commands.
:::

Use the [avn service update](/docs/tools/cli/service-cli) command to configure your
service so that it supports BTAR. Include `additional_backup_regions` as a parameter to
the command and set its value to the name of desired cloud region.
Expand All @@ -74,16 +68,6 @@ avn service update name_of_existing_service \
```
</TabItem>
<TabItem value="api" label="Aiven API">
Using [Aiven APIs](/docs/tools/api), you can enable BTAR for:

- [New Aiven service](#new-service-api) or
- [Existing Aiven service](#existing-service-api)

:::note[additional_backup_regions]
To enable BTAR on an Aiven service, include the `additional_backup_regions`
parameter in relevant calls.
:::

Use the [ServiceUpdate](https://api.aiven.io/doc/#tag/Service/operation/ServiceUpdate) API
to configure your existing service so that it supports BTAR. When constructing the API
request, add the `user_config` object to the request body and nest the
Expand Down Expand Up @@ -134,16 +118,6 @@ Your new additional backup is now visible on your service's **Backups** page in
**Secondary backup location** column.
</TabItem>
<TabItem value="cli" label="Aiven CLI">
Using the [Aiven CLI client](/docs/tools/cli), you can enable BTAR for

- [New Aiven service](#new-service-cli) or
- [Existing Aiven service](#existing-service-cli)

:::note[additional_backup_regions]
To enable BTAR on an Aiven service, add the `additional_backup_regions`
parameter to relevant commands.
:::

Use the [avn service create](/docs/tools/cli/service-cli) command to create a
service. Include `additional_backup_regions` as a parameter to the command and set its
value to the name of the desired cloud region.
Expand All @@ -159,16 +133,6 @@ avn service create \

</TabItem>
<TabItem value="api" label="Aiven API">
Using [Aiven APIs](/docs/tools/api), you can enable BTAR for:

- [New Aiven service](#new-service-api) or
- [Existing Aiven service](#existing-service-api)

:::note[additional_backup_regions]
To enable BTAR on an Aiven service, include the `additional_backup_regions`
parameter in relevant calls.
:::

Use the [ServiceCreate](https://api.aiven.io/doc/#tag/Service/operation/ServiceCreate) API
to create a service with BTAR enabled. When constructing the API request, add the
`user_config` object to the request body and nest the `additional_backup_regions`
Expand Down
126 changes: 101 additions & 25 deletions docs/platform/howto/btar/manage-backup-to-another-region.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,29 @@ limited: true
---

import RelatedPages from "@site/src/components/non-swizzled/RelatedPages";
import ConsoleLabel from "@site/src/components/non-swizzled/ConsoleIcons";
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

For a service that has the [backup to another region (BTAR)](/docs/platform/concepts/backup-to-another-region) feature [enabled](/docs/platform/howto/btar/enable-backup-to-another-region), you can check the service backup status, change the backup region, monitor the replication lag, fork and restore using [the cross-region backup](/docs/platform/concepts/backup-to-another-region), or migrate to another cloud or region.

## Prerequisites

You have at least one
[Aiven service with BTAR enabled](/docs/platform/howto/btar/enable-backup-to-another-region).
- At least one
[Aiven service with BTAR enabled](/docs/platform/howto/btar/enable-backup-to-another-region)
- Access to the [Aiven Console](https://console.aiven.io/)
- [Aiven API](/docs/tools/api)
- - [Aiven CLI](/docs/tools/api)

## Change a backup region

1. Log in to the [Aiven Console](https://console.aiven.io/).
1. From the **Services** view, select an Aiven service on which you'd like to enable BTAR.
1. On your service's page, select **Backups** from the sidebar.
1. On the **Backups** page, select the actions (**...**) menu > **Secondary backup
location**.
1. In the **Edit secondary backup location** window, use the **Secondary location**
1. Log in to the [Aiven Console](https://console.aiven.io/) and go to your project.
1. On the <ConsoleLabel name="Services"/> page, select an Aiven service on which you'd
like to enable BTAR.
1. On your service page, click <ConsoleLabel name="backups"/> in the sidebar.
1. On the **Backups** page, click <ConsoleLabel name="actions"/> >
**Edit secondary backup location**.
1. 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**.

Expand All @@ -41,13 +48,13 @@ BTAR:
- What is the replication lag between data availability in the primary region and the
secondary region?

### Check BTAR status in the console
### Check BTAR status

To see the availability, the status, and the target region of a secondary (BTAR)
backup in the [Aiven Console](https://console.aiven.io/), go to your
**service's page** > **Backups** view > **Secondary backup location** column.
service page > <ConsoleLabel name="backups"/> > **Secondary backup location**.

### Determine replication lag with API
### Determine replication lag

Determine the target region and the replication lag for a secondary (BTAR) backup of
your service, call the
Expand All @@ -56,8 +63,8 @@ endpoint.

Configure the call as follows:

1. Enter YOUR-PROJECT-NAME and YOUR-SERVICE-NAME into the URL.
1. Specify DESIRED-TIME-PERIOD depending on the time period you need the metrics for:
1. Enter `YOUR-PROJECT-NAME` and `YOUR-SERVICE-NAME` into the URL.
1. Specify `DESIRED-TIME-PERIOD` depending on the time period you need the metrics for:
select one of the following values for the `period` key: `hour`, `day`, `week`,
`month`, or `year`.

Expand All @@ -73,10 +80,10 @@ As output, you get metrics including replication lags at specific points in time

## Fork and restore a service with BTAR {#fork-and-restore}

You can use the [Aiven Console](https://console.aiven.io/) to recover your service from a
backup in another region. To restore your service using BTAR,
[create a fork](/docs/platform/concepts/service-forking) of the original service in the
region where the secondary backup resides.
You can use the [Aiven Console](/docs/tools/aiven-console), [API](/docs/tools/api), or
[CLI](/docs/tools/cli) to recover your service from a backup in another region. To restore
your service using BTAR, [create a fork](/docs/platform/concepts/service-forking) of the
original service in the region where the secondary backup resides.

:::note
When you **Fork & restore** from the secondary backup, your new fork service is created in
Expand All @@ -85,24 +92,93 @@ plan that the primary service uses. Backups of the fork service are located in t
where this new service is hosted.
:::

<Tabs groupId="group1">
<TabItem value="gui" label="Aiven Console" default>
1. Open the [Aiven Console](https://console.aiven.io/) and go to your service
homepage.
1. Select **Backups** from the sidebar.
1. Click <ConsoleLabel name="backups"/> in the sidebar.
1. On the **Backups** page, select **Fork & restore**.
1. In the **New database fork** window, apply the following settings:
1. In the **New database fork** window:

1. As **Source backup location**, select **Secondary location**.
<!--1. As **Source backup version**, select either **Latest transaction** or **Point in
time**.
1. Set **Backup location** to either **Primary location** or **Secondary location**.
1. Set **Backup version** to either **Latest transaction** or **Point in time**.

:::note
For the point-in-time recovery (PITR) option, set up the time to no later than the
time of taking the latest backup.
:::-->
For **Point in time**, set up the time to no later than the time of taking the
latest backup.
:::

1. Specify a name for the new fork service.
1. Select **Create fork**.

</TabItem>
<TabItem value="cli" label="Aiven CLI">

Run the [avn service create](/docs/tools/cli/service-cli#avn-cli-service-create) command
with the `--service-to-fork-from` option and the `--recovery-target-time`option. Set
`--recovery-target-time` to a point in time between the oldest replicated base backup and
your current time.

```bash {6,7}
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_NAME`
- `SERVICE_PLAN`
- `PROJECT_NAME`
- `SERVICE_TYPE`
- `SECONDARY_BACKUP_REGION`
- `PRIMARY_SERVICE_NAME`
- `YYYY-MM-DDTHH:MM:SS+00:00`

</TabItem>
<TabItem value="api" label="Aiven API">

Use the [ServiceCreate](https://api.aiven.io/doc/#tag/Service/operation/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 a point in time between
the oldest replicated base backup and your current time.

```bash
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_NAME`
- `SERVICE_PLAN`
- `PROJECT_NAME`
- `SERVICE_TYPE`
- `SECONDARY_BACKUP_REGION`
- `PRIMARY_SERVICE_NAME`
- `YYYY-MM-DDTHH:MM:SS+00:00`

</TabItem>
</Tabs>

## Migrate a service with BTAR

You can migrate a service with BTAR the same way you
Expand Down

0 comments on commit 7f1588e

Please sign in to comment.