Checkpoints and Forks
Checkpoints capture the state of an existing runtime so that you can restore it
into a new runtime later. The CLI command group is named snapshot; SDKs and
the REST API use checkpoint terminology.
Create a runtime and write state into it:
runta run --name <source_runtime_display_name> --cpus 2 --memory 1024runta exec <source_runtime_display_name> -- sh -lc 'echo hello-from-runtime > /tmp/hello.txt'from runta import Runta
runta = Runta()runtime = runta.runtimes.create("<source_runtime_display_name>", 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_runtime_display_name>", { vcpus: 2, memoryMiB: 1024,});await runtime.exec("echo hello-from-runtime > /tmp/hello.txt");Create a checkpoint:
runta snapshot create <source_runtime_display_name> <checkpoint_name>checkpoint = runtime.checkpoints.create(name="<checkpoint_name>")const checkpoint = await runtime.checkpoints.create("full", "<checkpoint_name>");List available checkpoints:
runta snapshot lscheckpoints = runta.checkpoints.list()for checkpoint in checkpoints: print(checkpoint.id, checkpoint.state)Restore the checkpoint into a new runtime:
runta snapshot restore <checkpoint_name> <restored_runtime_display_name>restored = runta.runtimes.create( "<restored_runtime_display_name>", checkpoint_id=checkpoint.id,)const restored = await runtime.restore(checkpoint.id, { name: "<restored_runtime_display_name>",});Verify that the restored runtime contains the captured state:
runta exec <restored_runtime_display_name> -- 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 snapshot restore <checkpoint_name> <fork_runtime_display_name>fork = runta.runtimes.create("<fork_runtime_display_name>", checkpoint_id=checkpoint.id)const fork = await runtime.restore(checkpoint.id, { name: "<fork_runtime_display_name>",});