Skip to main content
Backups capture the state of a directory inside your sandbox at a specific moment. Use them before risky operations, deployments, or as part of a CI pipeline.

Create a backup

pocketenv backup create my-sandbox /app \
  --description "before-deploy" \
  --ttl 7d
Arguments:
  • <sandbox> — target sandbox
  • <directory> — absolute path to the directory to back up
Options:
  • --description, -d — optional label for the backup
  • --ttl, -t — how long to keep the backup (e.g. 10m, 2h, 7d). Default: 3d

SDK

const backup = await sandbox.createBackup("/app", {
  description: "before-deploy",
  ttl: "7d",
});
console.log(backup.id); // bkp_01jqwerty123456789

List backups

pocketenv backup list my-sandbox
pocketenv backup ls my-sandbox   # alias
Output includes backup ID, directory, description, and expiry time.

SDK

const backups = await sandbox.listBackups();
// [{ id: "bkp_...", directory: "/app", description: "before-deploy", expiresAt: ..., createdAt: "..." }]

Restore a backup

pocketenv backup restore bkp_01jqwerty123456789
This replaces the backed-up directory with the snapshot content.
Restoring overwrites the current state of the directory. Make sure to back up first if you want to preserve current changes.

SDK

await Sandbox.restoreBackup("bkp_01jqwerty123456789");

TTL reference

ValueDuration
10m10 minutes
2h2 hours
1d1 day
7d7 days (max recommended)
Backups expire automatically after their TTL — they are not permanent storage.

Example: pre-deployment workflow

# Back up before deploying
pocketenv backup create prod /app --description "pre-v2.0" --ttl 48h

# Deploy
pocketenv exec prod "npm run deploy"

# If something went wrong
pocketenv backup list prod
pocketenv backup restore bkp_01jqwerty123456789

API