Skip to content

Rollback: snapshot pre-apply state and restore on failure or on demand #11

Description

@cl8dep

Problem

If dns-sync apply fails midway (network error, API rate limit, partial provider failure), records already applied cannot be reverted. The zone ends up in a partially-synced state with no recovery path.

Proposed solution

Automatic snapshot before apply

Before executing any changes, serialize the current state of each target provider zone to a local snapshot file:

.dns-sync/snapshots/{zone}/{provider}/{timestamp}.yaml

Rollback command

dns-sync rollback -c config.yaml                          # roll back to latest snapshot
dns-sync rollback -c config.yaml --snapshot 2024-01-15T10:30:00  # specific snapshot
dns-sync rollback -c config.yaml --zone example.com. --provider cloudflare

Automatic rollback on failure

# config.yaml
apply:
  rollback_on_failure: true   # auto-rollback if apply fails after partial changes

Implementation notes

  • Snapshot format can reuse the existing YAML zone file format
  • Snapshots should be stored alongside the config (or configurable path)
  • Rollback is itself an apply in reverse — reuses ApplyPlanAsync with source=snapshot, target=provider
  • Need to decide snapshot retention policy (keep last N, or by age)
  • Snapshots should be gitignore'd by default (contain live DNS state)

Related

  • Pairs well with an audit log feature to record what changed and when

Metadata

Metadata

Assignees

No one assigned

    Labels

    enterpriseEnterprise / production-grade featurefeatureNew feature or capability

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions