Skip to content

Add VM data backups guide (restic) - #232

Merged
HiranAdikari merged 2 commits into
wso2:terraformfrom
Akini98:docs/restic-vm-backup-guide
Jul 22, 2026
Merged

Add VM data backups guide (restic)#232
HiranAdikari merged 2 commits into
wso2:terraformfrom
Akini98:docs/restic-vm-backup-guide

Conversation

@Akini98

@Akini98 Akini98 commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Purpose

Resolves #231. The tenancy/vm examples document how to provision a VM but not how to back up its data. Product teams own their VM-data backups to their own S3 buckets and had no guide. This is the general-VM companion to the cluster backups guide (#219, etcd + Velero).

Goals

Provide a self-service VM-data backup + restore guide beside the tenancy/vm module, matching the style of k8s-cluster/examples/BACKUPS.md.

Approach

Add modules/tenancy/vm/examples/BACKUPS.md, covering:

  • Bucket + IAM — least-privilege policy JSON (including the multipart actions restic needs) plus a repository password, with an AWS-Console note.
  • In-guest install — cloud-init that base64-embeds the restic env, backup script, and a systemd backup .timer, passed via the vm module's user_data; MAC-agnostic netplan so a restored VM still gets an IP.
  • Verify + restore — into a fresh VM (same DC), a single file / subtree (file-level via restore --include / dump / mount), and cross-DC DR reading the same bucket.
  • Reference — a scheduling/retention table and a production-hardening checklist.

Release note

Docs: add a self-service restic VM-data backup + restore guide for the tenancy/vm module.

Documentation

This PR is documentation: modules/tenancy/vm/examples/BACKUPS.md.

Summary by CodeRabbit

  • Documentation
    • Added a comprehensive guide for backing up standalone virtual machine data with restic.
    • Documented encrypted backups to S3-compatible storage, including setup, scheduling, retention, and verification.
    • Added restore procedures for complete snapshots, individual files, and cross-datacenter disaster recovery.
    • Included operational considerations and production hardening recommendations.

@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

No new commits to review since the last review.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 05b30ce4-2a4b-444b-bd36-073952ecd80a

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds a restic-based VM application-data backup and restore guide covering S3 setup, Terraform/cloud-init automation, verification, same- and cross-datacenter recovery, retention, and production hardening.

Changes

VM restic backups

Layer / File(s) Summary
Repository preparation and VM configuration
modules/tenancy/vm/examples/BACKUPS.md
Documents S3 bucket and IAM setup, encrypted restic repository credentials, Terraform inputs, cloud-init scripts, and systemd backup scheduling.
Backup application and verification
modules/tenancy/vm/examples/BACKUPS.md
Adds Terraform apply instructions and verification steps for snapshots, repository health, timers, and follow-up backups.
Restore procedures and operational guidance
modules/tenancy/vm/examples/BACKUPS.md
Describes full, partial, and cross-datacenter restores, scheduling and retention, operational gotchas, production hardening, and related documentation.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related issues

  • Issue 231 — Directly corresponds to the added VM restic backup guide.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main change: adding a VM data backups guide with restic.
Description check ✅ Passed It covers purpose, goals, and approach, but omits the template's Testing and Checklist sections.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Akini98 Akini98 self-assigned this Jul 20, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🧹 Nitpick comments (1)
modules/tenancy/vm/examples/BACKUPS.md (1)

275-277: 🗄️ Data Integrity & Integration | 🔵 Trivial

Add a periodic restic check --read-data
restic check is still useful for routine metadata checks, but schedule a --read-data run (or a restore drill) so corruption in pack contents doesn’t go unnoticed.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@modules/tenancy/vm/examples/BACKUPS.md` around lines 275 - 277, Update the
backup verification instructions in BACKUPS.md to retain routine restic check
metadata validation and add a scheduled restic check --read-data run, or an
equivalent restore drill, to verify pack contents. Make the periodic
data-integrity check explicit alongside the existing restic snapshots and restic
check commands.

Source: MCP tools

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@modules/tenancy/vm/examples/BACKUPS.md`:
- Around line 148-155: Remove long-lived AWS credentials and the Restic
repository password from the user_data/restic_env cloud-init payload. Replace
this interpolation with a runtime secret-delivery mechanism; if that is not
possible, explicitly document and enforce protection of Terraform state and
harvester_cloudinit_secret access, including credential rotation and revocation
procedures.
- Line 281: Update the backup verification instructions around the aws s3 ls
example to run the command from the operator workstation rather than inside the
VM SSH block. Clearly label the execution context and preserve the existing
region and bucket arguments; do not require AWS CLI or S3 credential setup on
the VM.
- Line 164: Update the backup commands in BACKUPS.md to scope both restic
forget/prune and dump latest operations to the my-app tag by adding the
appropriate --tag my-app argument. Preserve the existing retention and restore
behavior, and note that shared repositories require one repository per workload.
- Line 194: Update the password value in the cloud-init YAML example to wrap
var.vm_password with jsonencode, ensuring passwords containing YAML-significant
characters are serialized as valid quoted strings.
- Around line 311-320: Update the restore examples in BACKUPS.md to run the
environment sourcing and restic restore, dump, and mount commands through sudo
bash -c. Before restic mount, install the required FUSE package and create
/mnt/restic with mkdir -p, preserving the existing restore, dump, and mount
examples.

---

Nitpick comments:
In `@modules/tenancy/vm/examples/BACKUPS.md`:
- Around line 275-277: Update the backup verification instructions in BACKUPS.md
to retain routine restic check metadata validation and add a scheduled restic
check --read-data run, or an equivalent restore drill, to verify pack contents.
Make the periodic data-integrity check explicit alongside the existing restic
snapshots and restic check commands.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b93aaa87-4c1d-49c4-8bc8-281b68cd59a0

📥 Commits

Reviewing files that changed from the base of the PR and between c67398b and 46c854c.

📒 Files selected for processing (1)
  • modules/tenancy/vm/examples/BACKUPS.md

Comment thread modules/tenancy/vm/examples/BACKUPS.md
Comment thread modules/tenancy/vm/examples/BACKUPS.md
Comment thread modules/tenancy/vm/examples/BACKUPS.md Outdated
Comment thread modules/tenancy/vm/examples/BACKUPS.md Outdated
Comment thread modules/tenancy/vm/examples/BACKUPS.md Outdated
docs: apply review feedback to modules/tenancy/vm/examples/BACKUPS.md
- note that restic_env lands in the cloud-init Secret + TF state; advise
  limiting access, least-priv IAM, and key rotation
- clarify the per-VM repo (prefix) and tag `restic dump` with my-app
- serialize the VM password with jsonencode for YAML-safe cloud-init
- drop the aws s3 ls check (restic snapshots/check already prove it)
- sudo-wrap the file-level restore/dump/mount; make mount optional and
  install FUSE + create the mountpoint first
@Akini98

Akini98 commented Jul 20, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@HiranAdikari
HiranAdikari merged commit 04353ac into wso2:terraform Jul 22, 2026
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants