Checkpoints and Forks
A checkpoint is a point-in-time capture of a runtime’s state, writable filesystem changes, and restore metadata such as vCPU, memory, CPU architecture, and pinned image hashes.
Create a runtime and write state into it:
runta run --name source-demo --cpus 2 --memory 1024runta exec source-demo -- sh -lc 'echo hello-from-runtime > /tmp/hello.txt'from runta import Runta
runta = Runta()runtime = runta.runtimes.create("source-demo", vcpus=2, memory_mib=1024)runtime.exec("echo hello-from-runtime > /tmp/hello.txt")import { Runta } from "@runta/runta-sdk";
const runta = new Runta();const runtime = await runta.runtimes.create("source-demo", { vcpus: 2, memoryMib: 1024,});await runtime.exec("echo hello-from-runtime > /tmp/hello.txt");Create a checkpoint:
runta checkpoint create source-demo source-demo-checkpointcheckpoint = runtime.checkpoints.create(name="source-demo-checkpoint")const checkpoint = await runtime.checkpoints.create("full", "source-demo-checkpoint");List available checkpoints:
runta checkpoint lscheckpoints = runta.checkpoints.list()for checkpoint in checkpoints: print(checkpoint.id, checkpoint.state)Restore the checkpoint into a new runtime:
runta checkpoint restore source-demo-checkpoint restored-demorestored = runta.runtimes.create( "restored-demo", checkpoint_id=checkpoint.id,)const restored = await runtime.restore(checkpoint.id, { name: "restored-demo",});Verify that the restored runtime contains the captured state:
runta exec restored-demo -- cat /tmp/hello.txtresult = restored.exec("cat /tmp/hello.txt")print(result.stdout_text)const result = await restored.exec("cat /tmp/hello.txt");console.log(result.stdoutText);Fork the same checkpoint into another runtime:
runta checkpoint restore source-demo-checkpoint fork-demofork = runta.runtimes.create("fork-demo", checkpoint_id=checkpoint.id)const fork = await runtime.restore(checkpoint.id, { name: "fork-demo",});