| name | tigris-snapshots-forking |
| description | Use when needing point-in-time recovery, version control for object storage, or creating isolated bucket copies for testing/experimentation |
Tigris Snapshots and Forking
Prerequisites
Before doing anything else, install the Tigris CLI if it's not already available:
tigris help || npm install -g @tigrisdata/cli
If you need to install it, tell the user: "I'm installing the Tigris CLI (@tigrisdata/cli) so we can work with Tigris object storage."
Overview
Snapshots capture your entire bucket at a point in time. Forking creates instant, isolated copies from snapshots using copy-on-write.
Core principle: Snapshots and forks protect your data from deletion. Even if you delete everything in a fork, the source bucket data remains intact.
Why Snapshots Matter
Object storage serves as the primary data store for many systems. It needs safety features:
- Point-in-time recovery - Restore after accidental deletion or corruption
- Version control - Tag meaningful states like releases
- Reproducibility - Recreate exact environments for debugging or testing
- Deletion protection - Forks can be destroyed without affecting source
Traditional object versioning only works per-object. To restore a bucket to a point in time, you must check and restore each object individually. Tigris snapshots capture the entire bucket state instantly.
Why Forking Matters
Forking creates isolated bucket copies instantly - even for terabytes of data:
- Developer sandboxes - Test with real production data safely
- AI agent environments - Spin up agents with pre-loaded dependencies
- Load testing - Use production data without risk
- Feature branch testing - Parallel environments for experiments
- Training experiments - Fork datasets to test without affecting source
How it works: Tigris uses immutable objects with backwards-ordered timestamps. Forks read from the parent snapshot until new data overwrites. This makes forking essentially free - no data copying required.
Quick Reference
| Operation | Function | Key Parameters |
|---|
| Create snapshot | createBucketSnapshot(options) | name, sourceBucketName |
| List snapshots | listBucketSnapshots(sourceBucketName) | sourceBucketName |
| Create fork | createBucket(name, options) | sourceBucketName, sourceBucketSnapshot |
Create Snapshot
import { createBucketSnapshot } from "@tigrisdata/storage";
const result = await createBucketSnapshot();
if (result.error) {
console.error("Error:", result.error);
} else {
console.log("Snapshot version:", result.data?.snapshotVersion);
}
const result = await createBucketSnapshot("my-bucket", {
name: "backup-before-migration",
});
if (result.error) {
console.error("Error:", result.error);
} else {
console.log("Named snapshot:", result.data?.snapshotVersion);
}
Prerequisite: Bucket must have enableSnapshot: true when created.
List Snapshots
import { listBucketSnapshots } from "@tigrisdata/storage";
const result = await listBucketSnapshots();
if (result.error) {
console.error("Error:", result.error);
} else {
console.log("Snapshots:", result.data);
}
const result = await listBucketSnapshots("my-bucket");
Create Fork from Snapshot
import { createBucket, createBucketSnapshot } from "@tigrisdata/storage";
const snapshot = await createBucketSnapshot("agent-seed", {
name: "agent-seed-v1",
});
const snapshotVersion = snapshot.data?.snapshotVersion;
const agentBucketName = `agent-${Date.now()}`;
const forkResult = await createBucket(agentBucketName, {
sourceBucketName: "agent-seed",
sourceBucketSnapshot: snapshotVersion,
});
if (forkResult.error) {
console.error("Error:", forkResult.error);
} else {
console.log("Forked bucket created");
}
Read from Snapshot Version
Access historical data without forking:
import { get, list } from "@tigrisdata/storage";
const result = await get("config.json", "string", {
snapshotVersion: "1751631910169675092",
});
const result = await list({
snapshotVersion: "1751631910169675092",
});
Deletion Protection in Action
import { remove, get } from "@tigrisdata/storage";
await remove("hello.txt", { config: { bucket: "agent-fork" } });
const forkResult = await get("hello.txt", "string", {
config: { bucket: "agent-fork" },
});
const sourceResult = await get("hello.txt", "string", {
config: { bucket: "agent-seed" },
});
The fork's deletion only affects the fork. Source data remains accessible in the parent bucket and all snapshots.
Use Cases
Developer Sandboxes
await createBucketSnapshot("production", {
name: "dev-sandbox-seed",
});
const devBucket = await createBucket(`dev-${developerName}`, {
sourceBucketName: "production",
sourceBucketSnapshot: "...",
});
AI Agent Environments
await put("model.bin", modelData);
await put("config.json", agentConfig);
const snapshot = await createBucketSnapshot("agent-seed", {
name: "v1",
});
const agentBucket = `agent-${Date.now()}`;
await createBucket(agentBucket, {
sourceBucketName: "agent-seed",
sourceBucketSnapshot: snapshot.data?.snapshotVersion,
});
await startAgent(agentBucket);
Pre-Migration Backups
await createBucketSnapshot("production", {
name: "before-migration-v2",
});
const rollback = await createBucket("production-restored", {
sourceBucketName: "production",
sourceBucketSnapshot: "...",
});
Common Mistakes
| Mistake | Fix |
|---|
| Snapshotting non-snapshot-enabled bucket | Recreate bucket with enableSnapshot: true |
| Expecting fork to affect source | Forks are isolated - source remains unchanged |
| Not naming snapshots | Names make snapshots discoverable |
| Using wrong storage tier | Snapshot buckets must use STANDARD tier |
Limitations
- Existing buckets cannot be snapshot-enabled (must create new bucket)
- Snapshot buckets require STANDARD storage tier
- Snapshot buckets don't support lifecycle transitions or TTL
How It Works (Deep Dive)
A snapshot is a single 64-bit integer representing nanoseconds since Unix epoch. Tigris stores objects with reverse-ordered timestamps, so the most recent version sorts first. When you snapshot, Tigris records the current time. Reading from a snapshot queries for the newest object version before that timestamp.
Forking adds recursive indirection: child bucket objects override the parent, but missing objects recurse through the parent snapshot. This makes forking instant - no data copying, just metadata pointers.