Skip to content

Commit

Permalink
Add docs for managed backup terraform provider attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
kathancox committed Nov 26, 2024
1 parent 3ed8ffb commit 5146f74
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
You may also want to configure the [managed backups]({% link cockroachcloud/managed-backups.md %}) your CockroachDB {{ site.data.products.standard }} cluster takes automatically. To do so, include the `backup_config` attribute in the `cockroach_cluster` resource:

{% include_cached copy-clipboard.html %}
~~~ hcl
backup_config = {
enabled = true
frequency_minutes = 60
retention_days = 30
}
~~~

{{site.data.alerts.callout_info}}
You can modify the [retention]({% link cockroachcloud/managed-backups.md %}#retention) of managed backups only once with either the [Cloud Console]({% link cockroachcloud/managed-backups.md %}#cloud-console), the [Cloud API]({% link cockroachcloud/managed-backups.md %}#cloud-api), or Terraform.
{{site.data.alerts.end}}

For details on setting each of the `backup_config` fields, refer to [Managed Backups]({% link cockroachcloud/managed-backups.md %}#cockroachdb-cloud-terraform-provider).
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Set the following for the `backup_config` attribute:

- `enabled` controls whether managed backups are enabled or disabled. If you are disabling managed backups, you cannot set backup frequency or retention. Possible values are: `true` or `false`.
- `frequency_minutes` determines [how often](#frequency) the managed backup will run in minutes. Possible values are: `5`, `10`, `15`, `30`, `60`, `240`, `1440`.
- `retention_days` sets the number of days Cockroach Labs will [retain](#retention) the managed backup in storage. You can change `retention_days` for the cluster **once** (whether in Terraform, the [Cloud API](#cloud-api), or the [Cloud Console](#cloud-console)). Possible values are: `2`, `7`, `30`, `90`, `365`. Note that:
- If the initial value of the `retention_days` attribute is the default value `30`, you'll be able to modify the backup retention setting once more.
- If the initial value is not the default, you will not be able to modify `retention_days` again. You can refrain from including `retention_days` in the Terraform configuration and instead manage the retention in the Cloud Console.

For more details on modifying `retention_days` more than once, refer to the [Updating Backup Retention](https://github.com/cockroachdb/terraform-provider-cockroach/blob/main/docs/guides/updating-backup-retention.md) documentation in the Terraform provider for CockroachDB {{ site.data.products.cloud }} Repository.
42 changes: 38 additions & 4 deletions src/current/cockroachcloud/managed-backups-advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ Configurable managed backup settings are available in all [supported versions]({

Full backups in the cluster will be deleted when they reach the set retention period. At this point, any incremental backups dependent on the deleted full backup will also be deleted. The Cloud Console will not list any backups that are beyond the set retention period, or incremental backups that cannot be restored.

For instructions on how to view and configure managed backup settings, use:
For instructions on how to view and configure managed backup settings, use the:

- The [Cloud Console](#cloud-console).
- The [Cloud API](#cloud-api).
- [Cloud Console](#cloud-console).
- [Cloud API](#cloud-api).
- [CockroachDB {{ site.data.products.cloud }} Terraform provider](#cockroachdb-cloud-terraform-provider).

{% include cockroachcloud/backups/full-backup-setting-change.md %}

Expand Down Expand Up @@ -239,4 +240,37 @@ For each restore job, the tab will display:

## Cloud API

{% include cockroachcloud/backups/cloud-api-get-put.md %}
{% include cockroachcloud/backups/cloud-api-get-put.md %}

## CockroachDB Cloud Terraform provider

You can use the [CockroachDB {{ site.data.products.cloud }} Terraform provider]({% link cockroachcloud/provision-a-cluster-with-terraform.md %}) to specify managed backup settings in {{ site.data.products.advanced }} clusters.

In your `main.tf` Terraform configuration file, use the `backup_config` attribute on the `cockroach_cluster` resource to modify the settings of managed backups. For example:

{% include_cached copy-clipboard.html %}
~~~ hcl
resource "cockroach_cluster" "advanced" {
name = "cockroach-advanced"
cloud_provider = "GCP"
plan = "ADVANCED"
dedicated = {
storage_gib = 15
machine_type = "n2-standard-4"
}
regions = [
{
name = "us-central1"
node_count = 1
}
]
delete_protection = true
backup_config = {
enabled = true
frequency_minutes = 60
retention_days = 30
}
}
~~~

{% include cockroachcloud/backups/terraform-managed-backups.md %}
43 changes: 39 additions & 4 deletions src/current/cockroachcloud/managed-backups.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ Configurable managed backup settings are available in all [supported versions]({

Full backups in the cluster will be deleted when they reach the set retention period. At this point, any incremental backups dependent on the deleted full backup will also be deleted. The Cloud Console will not list any backups that are beyond the set retention period, or incremental backups that cannot be restored.

For instructions on how to view and configure managed backup settings, use:
For instructions on how to view and configure managed backup settings, use the:

- The [Cloud Console](#cloud-console).
- The [Cloud API](#cloud-api).
- [Cloud Console](#cloud-console).
- [Cloud API](#cloud-api).
- [CockroachDB {{ site.data.products.cloud }} Terraform provider](#cockroachdb-cloud-terraform-provider).

{% include cockroachcloud/backups/full-backup-setting-change.md %}

Expand Down Expand Up @@ -125,4 +126,38 @@ To restore a cluster:

## Cloud API

{% include cockroachcloud/backups/cloud-api-get-put.md %}
{% include cockroachcloud/backups/cloud-api-get-put.md %}

## CockroachDB Cloud Terraform provider

You can use the [CockroachDB {{ site.data.products.cloud }} Terraform provider]({% link cockroachcloud/provision-a-cluster-with-terraform.md %}) to specify managed backup settings in {{ site.data.products.standard }} clusters.

In your `main.tf` Terraform configuration file, use the `backup_config` attribute on the `cockroach_cluster` resource to modify the settings of managed backups. For example:

{% include_cached copy-clipboard.html %}
~~~ hcl
resource "cockroach_cluster" "standard" {
name = "cockroach-standard"
cloud_provider = "GCP"
plan = "STANDARD"
serverless = {
usage_limits = {
provisioned_virtual_cpus = 2
}
upgrade_type = "AUTOMATIC"
}
regions = [
{
name = "us-east1"
}
]
delete_protection = false
backup_config = {
enabled = true
frequency_minutes = 60
retention_days = 30
}
}
~~~

{% include cockroachcloud/backups/terraform-managed-backups.md %}
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ In this tutorial, you will create a CockroachDB {{ site.data.products.standard }
- Under `usage_limits`, set `provisioned_virtual_cpus` to the required maximum vCPUs for the cluster.
- Under `regions`, add the names of one or more regions for the cluster.
- To optionally enable [deletion protection]({% link cockroachcloud/basic-cluster-management.md %}#enable-deletion-protection), set `delete_protection` to `true`.
{% include cockroachcloud/backups/provision-cluster-tf-managed-backups.md %}
{{ remaining_steps }}
{{site.data.alerts.callout_success}}
Expand Down Expand Up @@ -179,6 +181,8 @@ In this tutorial, you will create a CockroachDB {{ site.data.products.advanced }
- Under `dedicated`, set `storage_gib` to a value large enough to contain the cluster's expected data. Set `num_virtual_cpus` to the number of vCPUs per node.
- Under `regions`, add the names of one or more regions for the cluster and specify the `node_count`, or the number of nodes, per region.
- To optionally enable [deletion protection]({% link cockroachcloud/basic-cluster-management.md %}#enable-deletion-protection), set `delete_protection` to `true`.

{% include cockroachcloud/backups/provision-cluster-tf-managed-backups.md %}
{{ remaining_steps }}

</section>
Expand Down Expand Up @@ -255,3 +259,4 @@ Enter `yes` when prompted to delete the cluster.
- Read the [CockroachDB Cloud Terraform provider reference docs](https://registry.terraform.io/providers/cockroachdb/cockroach/latest/docs) in the Terraform registry, which provide detailed information on the resources you can manage using Terraform.
- Browse the [example recipes](https://github.com/cockroachdb/terraform-provider-cockroach/tree/main/examples) in the Terraform Provider's GitHub repository.
- Refer to the [Managed Backups]({% link cockroachcloud/managed-backups.md %}#cockroachdb-cloud-terraform-provider) page to configure the managed backups for your CockroachDB {{ site.data.products.cloud }} cluster.

0 comments on commit 5146f74

Please sign in to comment.