Skip to content

feat: add ignore-empty-snapshot backup option#191

Merged
rmanibus merged 1 commit into
mainfrom
feat/ignore-empty-snapshot
Apr 2, 2026
Merged

feat: add ignore-empty-snapshot backup option#191
rmanibus merged 1 commit into
mainfrom
feat/ignore-empty-snapshot

Conversation

@rmanibus
Copy link
Copy Markdown
Contributor

@rmanibus rmanibus commented Apr 2, 2026

Summary

  • add an opt-in backup option to skip creating a snapshot when the resulting tree is unchanged
  • expose the setting through the CLI, backup profiles, docs, and shell completion
  • add engine and CLI tests covering the ignored-empty-snapshot path

Testing

  • env GOCACHE=/tmp/cloudstic-gocache go test ./internal/engine -run 'TestBackupManager_(Run|IgnoreEmptySnapshot|ResolvesPathsForOpaqueIDs)|TestDetectChange_'
  • env GOCACHE=/tmp/cloudstic-gocache go test ./cmd/cloudstic -run 'Test(BuildBackupOpts_IgnoreEmptySnapshot|PrintBackupSummary_EmptySnapshotIgnored|MergeProfileBackupArgs_AppliesProfileAndStore|Completion(Bash|Zsh|Fish)|PrintUsage_Smoke)'

Closes #190

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 2, 2026

Codecov Report

❌ Patch coverage is 96.55172% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cmd/cloudstic/cmd_backup.go 90.00% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@rmanibus rmanibus requested a review from Copilot April 2, 2026 15:27
@rmanibus rmanibus merged commit 83dd0d8 into main Apr 2, 2026
14 checks passed
@rmanibus rmanibus deleted the feat/ignore-empty-snapshot branch April 2, 2026 15:30
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds an opt-in ignore-empty-snapshot backup option to skip snapshot creation when the resulting tree is unchanged from the previous snapshot for the same source lineage, and wires it through CLI, profiles, docs, and shell completions (Closes #190).

Changes:

  • Engine: add WithIgnoreEmptySnapshot and an EmptySnapshotIgnored run result flag, and short-circuit snapshot persistence when roots match.
  • CLI/profiles: expose -ignore-empty-snapshot in backup and profile new, profile YAML (ignore_empty), usage output, profile display, and shell completion.
  • Tests/docs: add engine + CLI tests for the ignored-empty-snapshot path and document behavior (including change-token implications for changes-based sources).

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
internal/engine/profiles.go Adds IgnoreEmpty to backup profile YAML schema.
internal/engine/backup.go Implements ignore-empty-snapshot option + result flag.
internal/engine/backup_test.go Adds engine test covering ignore-empty-snapshot behavior and index stability.
docs/user-guide.md Documents -ignore-empty-snapshot and its implications for changes-based sources.
cmd/cloudstic/usage.go Adds flag to usage output.
cmd/cloudstic/config_tables.go Displays profile setting in profile show.
cmd/cloudstic/completion.go Adds flag to bash/zsh/fish completions for backup and profile new.
cmd/cloudstic/completion_test.go Verifies completion output includes the new flag.
cmd/cloudstic/cmd_profile.go Adds flag to profile new and persists to profiles.yaml.
cmd/cloudstic/cmd_backup.go Adds CLI flag, merges profile setting, passes option to engine, updates summary output.
cmd/cloudstic/cmd_backup_test.go Adds tests for building opts and summary output when snapshot is ignored.
cmd/cloudstic/cmd_backup_profile_test.go Adds profile merge test coverage for ignore-empty setting.
client.go Re-exports WithIgnoreEmptySnapshot from engine.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/engine/backup.go
Comment on lines +257 to +262
if bm.cfg.ignoreEmptySnapshot && prevSnap != nil && newRoot == oldRoot {
r := bm.buildResult()
r.Root = newRoot
r.EmptySnapshotIgnored = true
return r, nil
}
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

The ignore-empty-snapshot fast-path runs after flushPendingMetas, PreloadKeys, and upload. On an unchanged backup pending is typically empty and newRoot == oldRoot, so PreloadKeys will still list all chunk/, content/, and node/ keys even though no upload is needed. Consider moving the ignore-empty check earlier (right after scanSource, gated on prevSnap != nil && len(pending)==0 && newRoot==oldRoot and optionally len(bm.pendingMetas)==0) so unchanged runs can return without the expensive key preloading step.

Copilot uses AI. Check for mistakes.
@rmanibus rmanibus added the enhancement New feature or request label Apr 2, 2026
@rmanibus rmanibus added this to the v1.14.0 milestone Apr 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add option to ignore empty backup snapshots

2 participants