GKE Backup and Disaster Recovery

GKE Backup and Disaster Recovery

Sets up Backup for GKE: the addon, backup and restore plans, restore workflows and CMEK-encrypted backups, with a ready CLI reference for stateful workloads.

Skill files2 files

references/

SKILL.md174 lines
1
---
2
name: gke-backup-dr
3
description: >-
4
Configures Backup for GKE: the BackupRestore cluster addon, BackupPlan and
5
RestorePlan resources, restore workflows, and CMEK-encrypted backups. Use
6
for backup policies, disaster recovery, or GKE cluster restores. Don't use
7
for database backups.
8
metadata:
9
version: "1.0.1"
10
category: Storage
11
---
12
13
# GKE Backup & Disaster Recovery
14
15
Protects stateful GKE workloads using Backup for GKE. Backup for GKE can capture
16
both Kubernetes resource metadata (manifests, configurations, and secrets) and
17
the underlying persistent volume (PV) data — but volume data and secrets are
18
**only** captured when the backup plan explicitly enables them (see the flags
19
below).
20
21
## Attribution
22
23
**MUST READ**: Before executing any `gcloud`, REST API, or MCP command, you
24
MUST read [Usage Attribution](references/attribution.md). For commands executed
25
directly in the terminal (never in generated scripts, Terraform, or user code),
26
prefix `gcloud` with
27
`CLOUDSDK_METRICS_REQUEST_ATTRIBUTION="agent-skills/1.0 (skill:gke-backup-dr)"`
28
and append `agent-skills/1.0 (skill:gke-backup-dr)` to `User-Agent` headers.
29
30
## CLI Reference
31
32
```bash
33
# Enable the BackupRestore addon (Slow cluster-level update)
34
gcloud container clusters update {cluster_name} \
35
--update-addons=BackupRestore=ENABLED --location={location} --quiet
36
37
# Create Backup Plan
38
gcloud beta container backup-restore backup-plans create {plan_name} \
39
--project={project_id} --location={location} \
40
--cluster=projects/{project_id}/locations/{location}/clusters/{cluster_name} \
41
--all-namespaces \
42
--include-volume-data --include-secrets \
43
--backup-retain-days={days} --cron-schedule="{cron}" --quiet
44
45
# Trigger Manual Backup
46
gcloud beta container backup-restore backups create {backup_name} \
47
--backup-plan={plan_name} --location={location} --quiet
48
49
# Create Restore Plan
50
gcloud beta container backup-restore restore-plans create {restore_plan_name} \
51
--location={location} \
52
--cluster=projects/{project_id}/locations/{location}/clusters/{target_cluster_name} \
53
--backup-plan=projects/{project_id}/locations/{location}/backupPlans/{source_backup_plan_name} \
54
--all-namespaces \
55
--cluster-resource-conflict-policy=use-existing-version \
56
--namespaced-resource-restore-mode=fail-on-conflict --quiet
57
58
# Execute Restore
59
gcloud beta container backup-restore restores create {restore_name} \
60
--restore-plan={restore_plan_name} --location={location} \
61
--backup=projects/{project_id}/locations/{location}/backupPlans/{source_backup_plan_name}/backups/{backup_name} \
62
--quiet
63
64
# Verify Restore Status
65
gcloud beta container backup-restore restores describe {restore_name} \
66
--restore-plan={restore_plan_name} --location={location}
67
```
68
69
> [!WARNING] **`--include-volume-data` and `--include-secrets` BOTH DEFAULT TO
70
> FALSE.** If you omit them, the backup plan silently produces **config-only
71
> backups** with no persistent volume snapshots and no Secrets. Always pass both
72
> flags explicitly when the goal is full workload protection.
73
74
Notes:
75
76
- The `backup-restore` command group requires the `gcloud beta` component
77
(`gcloud components install beta`).
78
- `--cluster` requires the full resource path
79
`projects/{project_id}/locations/{location}/clusters/{cluster_name}` (or
80
`projects/{project_id}/zones/{zone}/clusters/{cluster_name}` for zonal
81
clusters), not a bare cluster name.
82
- Restore plans require exactly one namespaced-resource scope flag:
83
`--all-namespaces`, `--selected-namespaces={ns1},{ns2}`,
84
`--excluded-namespaces=...`, `--selected-applications=...`, or
85
`--no-namespaces`.
86
87
## Restore Safety (CRITICAL)
88
89
A restore writes into a **live cluster** and, depending on the conflict policy,
90
can overwrite or delete existing resources:
91
92
- `--cluster-resource-conflict-policy=use-existing-version` keeps existing
93
cluster-scoped resources (safe default); `use-backup-version` **deletes**
94
the existing version first — deleting a CRD deletes all of its CRs.
95
- `--namespaced-resource-restore-mode=fail-on-conflict` aborts on any conflict
96
(safe default); `merge-skip-on-conflict` skips conflicting resources;
97
`merge-replace-on-conflict` and `merge-replace-volume-on-conflict`
98
**overwrite** existing resources or volumes; `delete-and-restore` **deletes
99
entire conflicting namespaces** (and all resources in them) before
100
restoring.
101
102
**Rules:**
103
104
1. Validate the restore in a non-production target cluster first.
105
2. Prefer the safe defaults (`use-existing-version` + `fail-on-conflict`)
106
unless the user explicitly needs to revert live resources.
107
3. **Always obtain explicit user confirmation before executing a restore into a
108
production cluster**, and state which conflict policy is in effect and what
109
it may overwrite or delete.
110
111
## Best Practices
112
113
1. **CMEK Encryption**: Encrypt backup plans using Customer-Managed Encryption
114
Keys:
115
`--encryption-key=projects/{project_id}/locations/{location}/keyRings/{ring}/cryptoKeys/{key}`.
116
2. **Scope**: Prefer backing up specific namespaces rather than the entire
117
cluster: `--selected-namespaces={ns1},{ns2}` (instead of
118
`--all-namespaces`).
119
3. **Application Consistency**: Recommend quiescing the database or pausing
120
application writes (e.g. using pre-backup hooks or database-specific tools)
121
prior to backups to ensure data integrity.
122
4. **CSI Volume Snapshots**: Ensure that stateful backups utilize GKE's CSI
123
(Container Storage Interface) driver for volume snapshots to capture
124
persistent volume data.
125
5. **Service Terminology**: Always explicitly refer to the service as **Backup
126
for GKE** in your response. This distinguishes it from the broader (but
127
complementary) Google Cloud **Backup and Disaster Recovery (DR)
128
Service**, ## Golden Path Backup Defaults
129
130
The recommended production golden path configuration for Backup for GKE:
131
132
- **Addon**: BackupRestore addon enabled
133
(`--update-addons=BackupRestore=ENABLED`).
134
- **Volume Inclusion**: `--include-volume-data` explicitly passed (enabled,
135
since the service default is false).
136
- **Secret Inclusion**: `--include-secrets` explicitly passed (enabled, since
137
the service default is false).
138
- **Retention**: Defined retention period (e.g. 30 days via
139
`--backup-retain-days=30`).
140
- **Encryption**: CMEK enabled (`--encryption-key=...`).
141
142
## Recent Changes
143
144
- **Cross-project backup and restore (GA)**: Backup plans can store backups in
145
a different project than the source cluster, and restore plans can target
146
clusters in a third project. Enables centralized backup projects (with
147
immutability/retention managed by a platform team) and cross-project
148
environment seeding without granting access to the source project.
149
- **Pricing change (effective 2026-03-02)**: The backup management fee moved
150
from **pod-based** to **NAMESPACE-based** pricing — charged per non-system
151
namespace in the most recent successful backup of each plan (system
152
namespaces like `kube-system` are excluded). Existing committed use discount
153
(CUD) holders keep pod-based management pricing until their commitment ends;
154
everyone else moves to the new model. See
155
https://cloud.google.com/products/backup-for-gke/pricing-changes.
156
- **Smart Scheduling**: RPO-driven backup scheduling as an alternative to
157
fixed cron schedules — pass `--target-rpo-minutes={minutes}` instead of
158
`--cron-schedule` when creating the backup plan (optionally with RPO
159
exclusion windows via `--exclusion-windows-file`).
160
- **Hyperdisk support**: Backup and restore of **Hyperdisk ML** and
161
**Hyperdisk Balanced High Availability** volumes is supported on GKE
162
clusters running **1.33.1-gke.1959000 and later** (Hyperdisk throughput,
163
extreme, and balanced types are also supported).
164
165
## Troubleshooting & Common Pitfalls (CRITICAL)
166
167
> [!IMPORTANT] **Slow Operations**: Enabling the BackupRestore addon
168
> (`--update-addons=BackupRestore=ENABLED`) triggers a slow Google Cloud control
169
> plane cluster update that takes several minutes. * **Rule**: **Do not run a
170
> terminal loop waiting for the GKE Backup addon to become active.** *
171
> **Action**: Provide the command to enable the addon, explain that the
172
> operation will proceed in the background, and immediately proceed to write the
173
> backup plan configs. Do not block.
174

© Google LLC · Apache 2.0 · source · posted by @OpenSourceBuffGuy on promptparty.com

@OpenSourceBuffGuy

I find openly licensed prompts and post them here.

0 followers · 14,621 prompts

More by @OpenSourceBuffGuy

See all
Sea turtle carrying floating film studio island prompt image

Sea turtle carrying floating film studio island

Draws a giant sea turtle carrying a floating island film studio through a starry sky, where fairies polish rough film strips into golden film.

image-prompt, nano-banana, 3d-render, cartoon, fantasy-world, creatures, animals, whimsical, dreamy, cinematic, dramatic-lighting, vibrant-colors, bokeh, miniature, widescreen, night-scene, illustration, concept-art, surreal, storytelling, clay-3d

Desert buggy escapes drones past industrial outpost prompt image

Desert buggy escapes drones past industrial outpost

Builds a 15-second desert chase video where a racer in an armored buggy escapes drones past an industrial outpost, using five reference images with set jobs.

video-prompt, hailuo, action, multi-shot, timed-beats, camera-movement, reference-image, character-consistency, negative-prompt, cinematic, sci-fi, cars, landscape, aerial-view, tracking-shot, photorealistic, sound-effects, structured-output, long-form, widescreen

1 view
Cozy Pixel Art Farm Island Village prompt image

Cozy Pixel Art Farm Island Village

Draws a cozy 16-bit pixel-art farming village across six small islands joined by bridges, with exact counts for buildings, animals and crops.

image-prompt, gpt-image, pixel-art, isometric, game-assets, concept-art, maps, worldbuilding, cozy, vibrant-colors, ocean, landscape, wide-shot, widescreen, game-development, video-games, structured-output, whimsical, summer, high-angle, aerial-view, animals, negative-prompt, cityscape

1 view

Reviews

Loading reviews…

Discussion

Loading comments…