Skip to content

[Feature]: Exclude node_modules from extensions in backup archive #64144

Description

@BrilliantWang

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions