openclaw - ✅(Solved) Fix [Feature]: Exclude node_modules from extensions in backup archive [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#64144Fetched 2026-04-11 06:16:16
View on GitHub
Comments
0
Participants
1
Timeline
2
Reactions
0
Participants
Timeline (top)
cross-referenced ×1referenced ×1

Exclude node_modules directories inside extensions/ when creating backup archives to reduce backup size significantly.

Root Cause

Exclude node_modules directories inside extensions/ when creating backup archives to reduce backup size significantly.

Fix Action

Fix / Workaround

  1. Skip entire extensions/ directory -- too aggressive; config references plugins and restore would fail without them.
  2. Add --exclude-extensions CLI flag -- more flexible but adds complexity; the default behavior should be smart enough.
  3. Wrapper script -- fragile workaround that does not help other users.

PR fix notes

PR #64148: backup: exclude node_modules inside extensions from archive

Description (problem / solution / changelog)

Summary

  • Filter out node_modules directories inside extensions/ when creating backup archives
  • Extension manifests, config, and plugin source are still included
  • Dependencies can be reinstalled after restore via npm install --omit=dev

Closes #64144

Motivation

openclaw backup create archives the entire state directory, including ~/.openclaw/extensions/*/node_modules/. These dependency trees are often hundreds of MB, are trivially reinstallable, and may contain platform-specific native modules that won't work cross-platform anyway.

Changes

  • Added a filter callback to tar.c() in src/infra/backup-create.ts that skips any path containing node_modules within the extensions/ subtree of the state directory
  • Extracted the filter as buildExtensionsNodeModulesFilter() for testability
  • Added unit tests covering: non-extension paths pass through, extension files pass through, node_modules inside extensions are excluded, nested node_modules are excluded, node_modules outside extensions are not affected

Test plan

  • Unit tests for buildExtensionsNodeModulesFilter added and passing
  • Manual: run openclaw backup create with installed extensions, verify archive does not contain node_modules under extensions
  • Manual: restore from the archive, run npm install --omit=dev in extension dirs, verify plugins work

Changed files

  • src/infra/backup-create.test.ts (modified, +49/-1)
  • src/infra/backup-create.ts (modified, +23/-0)
RAW_BUFFERClick to expand / collapse

Summary

Exclude node_modules directories inside extensions/ when creating backup archives to reduce backup size significantly.

Problem to solve

openclaw backup create archives the entire state directory including ~/.openclaw/extensions/*/node_modules/. These dependency trees are large (often hundreds of MB) and can be trivially reinstalled via npm install --omit=dev. Including them inflates backup archives unnecessarily and makes backup/restore slower.

Additionally, native modules in node_modules may not be compatible across platforms, so restoring them as-is can still require reinstallation.

Proposed solution

Add a filter callback to the tar.c() call in src/infra/backup-create.ts that skips node_modules directories within the extensions/ subtree of the state directory. This preserves plugin source code, manifests, and configuration while excluding reinstallable dependencies.

After restoring, users would run npm install --omit=dev in each extension directory to restore dependencies -- the same flow as initial plugin installation.

Alternatives considered

  1. Skip entire extensions/ directory -- too aggressive; config references plugins and restore would fail without them.
  2. Add --exclude-extensions CLI flag -- more flexible but adds complexity; the default behavior should be smart enough.
  3. Wrapper script -- fragile workaround that does not help other users.

Impact

  • Affected: all users running openclaw backup create with installed plugins
  • Severity: medium (bloated backups, slow transfers)
  • Frequency: every backup
  • Consequence: unnecessarily large archive files; wasted disk/bandwidth on every backup cycle

extent analysis

TL;DR

Implement a filter callback in the tar.c() call to exclude node_modules directories within the extensions/ subtree when creating backup archives.

Guidance

  • Modify the src/infra/backup-create.ts file to add a filter callback to the tar.c() call, skipping node_modules directories within the extensions/ subtree.
  • After restoring, run npm install --omit=dev in each extension directory to restore dependencies.
  • Test the updated backup and restore process to ensure that plugin source code, manifests, and configuration are preserved, while reinstallable dependencies are excluded.
  • Verify that the backup archive size is significantly reduced and the restore process is faster.

Example

// src/infra/backup-create.ts
tar.c({
  // ...
  filter: (path) => {
    const parts = path.split('/');
    return !parts.includes('node_modules') || !parts.includes('extensions');
  },
  // ...
})

Notes

This solution assumes that the tar.c() call is the correct place to implement the filter callback. Additionally, the npm install --omit=dev command should be run in each extension directory after restoring to ensure that dependencies are properly reinstalled.

Recommendation

Apply workaround: Implement the filter callback in the tar.c() call to exclude node_modules directories, as this solution is more efficient and effective than alternative approaches.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING