Snapshots
A snapshot saves a running sandbox so another can start where it was. Modal saves three things: the whole filesystem as an image, the memory with its running processes, or one directory to mount elsewhere.
A copy starts where the original was
Section titled “A copy starts where the original was”The original keeps running after a snapshot. Every copy starts from the saved state, and changes only its own files:
Save the filesystem as an image
Section titled “Save the filesystem as an image”yield* sandbox.exec(["pnpm", "install"], { cwd: "/work" });const image = yield* sandbox.snapshotFilesystem();The result is an image. Pass it to create:
const next = yield* sandboxes.create({ image });Save memory and running processes
Section titled “Save memory and running processes”A sandbox created with enableSnapshot can save its memory too. The copy resumes with its processes running:
const sandbox = yield* sandboxes.create({ enableSnapshot: true });const snapshot = yield* sandbox.snapshotMemory();const restored = yield* sandboxes.restore(snapshot, { name: `session-${user}` });Move one directory to another sandbox
Section titled “Move one directory to another sandbox”const workspace = yield* sandbox.snapshotDirectory("/work");yield* other.mountDirectory("/work", workspace);other gets a copy of /work and nothing else from the original.