Skip to content

fix(backups): back up only Lens's own files, so upgrading in a microsandbox works - #403

Merged
adeelahmad merged 3 commits into
mainfrom
claude/project-thread-t3gsjl
Oct 15, 2026
Merged

adeelahmad merged 3 commits into
mainfrom
claude/project-thread-t3gsjl

Conversation

@adeelahmad

Copy link
Copy Markdown
Owner

Requested by Adeel · project thread

Description

Before: in a microsandbox, Settings › Updates › Back up and install v0.10.0 failed with backing up failed: [Errno 13] Permission denied: '/data/.lens/apt/lock', and every manual or scheduled backup failed the same way. The step list showed Back up the database as done and Download the new version as failed.

After: backups keep only Lens's own files, so the backup and the upgrade go through. When a backup does stop an upgrade, Back up the database is the step marked failed.

Since #385 a backup keeps every file under data_dir. In a microsandbox data_dir is the whole /data volume, which also holds .lens (the Lens the sandbox runs: apt, the venv, node, the web build, partly root's), .cache, .pnpm-store and SurrealDB's own folder surreal. The first unreadable file, .lens/apt/lock, failed the whole backup.

How: datafiles now leaves out hidden entries at the top of data_dir and surreal, both when backing up and when restoring. The export already holds the database, and copying a live surrealkv folder wouldn't give a consistent copy anyway. A file Lens can't read is left out with one warning in the log, and the backup carries on. _hand_over records step: backup when backing up fails, and the updates panel marks that step.

Motivation and Context

Adeel's install (microsandbox, v0.9.0) couldn't install v0.10.0 from the web app. The traceback in his Lens log:

File "/data/.lens/backend/app/domain/datafiles.py", line 122, in snapshot
    shutil.copy2(src, out)
PermissionError: [Errno 13] Permission denied: '/data/.lens/apt/lock'

It would also crash-loop the API in a microsandbox whenever a release brings database upgrade steps, because migrations._backup_before takes the same backup at start.

Steps to reproduce (if appropriate):

Microsandbox install on v0.9.0 or later: Settings › Updates › Back up and install, or Settings › Backups › Back up now. test_a_microsandbox_backs_up_only_lenss_own_files reproduces it: it fails on main with the same PermissionError and passes here.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change; ! in the title)

Checklist:

  • The title is a Conventional Commit.
  • My code follows the code style of this project (make hooks checks it on commit).
  • I added or updated tests.
  • My change requires documentation updates, and I have updated docs/ accordingly.
  • Users need more than the title to understand it, so I wrote it under ## Unreleased in CHANGELOG.md.

Done questions (AGENTS.md)

  • Goal: Adeel can install updates from the web app again. Merges on green CI.
  • Agents: POST /api/v1/admin/updates/upgrade and POST /api/v1/admin/backups work the same, and the run's step says which step failed.
  • Zero setup: nothing new to set up.
  • Fewest clicks: one click upgrades again.
  • Configurable: n/a, no new settings.
  • Light: backups get smaller in a microsandbox, because the install tree and caches are no longer copied.
  • Private and secure: n/a, no new surface. The backup folder no longer gets copies of root-owned install files.
  • Cost: n/a, no model calls.
  • User decides: upgrades still start only when an admin asks; defaults unchanged.
  • Upgrades: no stored-data change. Restoring an older backup skips hidden top-level entries.
  • Honest: the changelog and docs say what is left out and why.
  • Tests, docs and generated files: tests added, docs/database.md updated, OpenAPI and client regenerated with make openapi.
  • Open standards: n/a, no new dependencies.
  • Reported: in the project thread, with the log above. Refine later: an install that is already on v0.10.0 or older takes its pre-upgrade backup with the old code, so its first upgrade off it needs the install line or an upgrade with backup: false.

🤖 Generated with Claude Code

https://claude.ai/code/session_01GMryXNWd5MJ3vsjM7RkV93


Generated by Claude Code

…andbox works

Back up and install in Settings stopped at the backup with "Permission denied:
'/data/.lens/apt/lock'" in a microsandbox, and so did every backup there: since
backups keep the files under data_dir, they walked into /data/.lens, the Lens
the microsandbox runs (apt, the venv, the web build, some of it root's).

Backups now leave out hidden entries at the top of data_dir (.lens, caches) and
SurrealDB's own folder (surreal; the export holds the database), and a file Lens
can't read is left out with a warning instead of stopping the backup. A backup
that stops an upgrade marks "Back up the database" as the failed step, not
"Download the new version".

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GMryXNWd5MJ3vsjM7RkV93
@adeelahmad adeelahmad self-assigned this Oct 15, 2026
@adeelahmad
adeelahmad merged commit 1563095 into main Oct 15, 2026
10 checks passed
@adeelahmad
adeelahmad deleted the claude/project-thread-t3gsjl branch October 15, 2026 12:19
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.

2 participants