Skip to content

feat(backup): add .gitignore-like exclude patterns support#1

Open
verncake wants to merge 10 commits into
mainfrom
feature/backup-exclude-patterns
Open

feat(backup): add .gitignore-like exclude patterns support#1
verncake wants to merge 10 commits into
mainfrom
feature/backup-exclude-patterns

Conversation

@verncake
Copy link
Copy Markdown
Owner

@verncake verncake commented Mar 9, 2026

Summary

  • Problem: The backup CLI does not support excluding specific files/directories, leading to large backup sizes and potential inclusion of sensitive files
  • Why it matters: Users cannot exclude node_modules, .env, logs, or other unnecessary files from backups
  • What changed: Added --exclude and --exclude-file options, plus auto-loading of .gitignore and .openclawignore from workspace directories
  • What did NOT change: Existing backup functionality, manifest format, verification logic

Change Type

  • Feature

Scope

  • Gateway / orchestration

Linked Issue/PR

User-visible / Behavior Changes

  • New CLI options: --exclude <pattern>, --exclude-file <path>
  • Auto-detection of .gitignore and .openclawignore in workspace directories
  • Excluded files shown in backup output with reason "excluded"

Security Impact

  • New permissions/capabilities? No
  • Secrets/tokens handling changed? No
  • New/changed network calls? No
  • Command/tool execution surface changed? Yes - New CLI options added
  • Data access scope changed? No

Risk is low - excludes files from backup only, no new permissions

Repro + Verification

Environment

  • OS: Linux
  • Runtime: Node.js 24.x

Steps

  1. Run openclaw backup create --exclude "node_modules"
  2. Verify node_modules is excluded from backup

Evidence

  • Test output showing excluded files

Human Verification

  • Verified scenarios: Created backup with --exclude "node_modules", confirmed pattern matching works

Compatibility / Migration

  • Backward compatible? Yes
  • Config/env changes? No
  • Migration needed? No

Risks and Mitigations

  • Risk: Pattern matching might miss some edge cases
  • Mitigation: Supports basic glob patterns (*, ?)

Verncake added 10 commits March 9, 2026 16:56
- Add --exclude <pattern> option to exclude specific patterns
- Add --exclude-file <path> option to read patterns from file
- Support basic glob patterns (* and ?)
- Filter assets before creating tar archive
- Show excluded files in skipped list
- Include excludePatterns in manifest for verification

Closes openclaw#40786
- Automatically find and load .gitignore and .openclawignore files
- Load patterns from each workspace directory
- Patterns are applied to backup archive
…lude-file

- Escape regex special characters before pattern compilation
- Add required parameter to loadExcludePatternsFromFile
- Throw error when user-specified exclude file cannot be loaded

Fixes review comments
- Test basic --exclude pattern matching
- Test regex special character escaping
- Test --exclude-file loading
- Test error when exclude file doesn't exist
- Test auto-loading .gitignore from workspace
- Test multiple --exclude patterns
- Fix ? wildcard to work independently without *
- Fix substring matching to use exact/basename match
- Normalize workspace ignore patterns
- Add tar filter to exclude individual entries within archived dirs

Fixes review comments
- Add negation patterns (! prefix)
- Add character classes [abc]
- Add character ranges [a-z]
- Add double wildcard ** for recursive matching
- Handle negation in filter logic

Closes openclaw#40786
- Import collectOption from helpers.ts
- Use collectOption for --exclude option
- Fix TypeScript type error
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.

Feature Request: Add .gitignore-like exclude patterns to backup CLI

1 participant