UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

42 lines (41 loc) 3.13 kB
import { t as formatDocsLink } from "./links-CsLBrRff.js"; import { r as theme } from "./theme-vjDs9tao.js"; import { n as defaultRuntime } from "./runtime-B4lgFmsS.js"; import { n as runCommandWithRuntime } from "./cli-utils-Cuzzfy1Q.js"; import { t as formatHelpExamples } from "./help-format-CAcwboTs.js"; import { t as backupVerifyCommand } from "./backup-verify-D2nTdZHf.js"; import { t as backupCreateCommand } from "./backup-bzVmvoUY.js"; //#region src/cli/program/register.backup.ts /** Register backup create/verify subcommands. */ function registerBackupCommand(program) { const backup = program.command("backup").description("Create and verify local backup archives for OpenClaw state").addHelpText("after", () => `\n${theme.muted("Docs:")} ${formatDocsLink("/cli/backup", "docs.openclaw.ai/cli/backup")}\n`); backup.command("create").description("Write a backup archive for config, credentials, sessions, and workspaces").option("--output <path>", "Archive path or destination directory").option("--json", "Output JSON", false).option("--dry-run", "Print the backup plan without writing the archive", false).option("--verify", "Verify the archive after writing it", false).option("--only-config", "Back up only the active JSON config file", false).option("--no-include-workspace", "Exclude workspace directories from the backup").addHelpText("after", () => `\n${theme.heading("Examples:")}\n${formatHelpExamples([ ["openclaw backup create", "Create a timestamped backup in the current directory."], ["openclaw backup create --output ~/Backups", "Write the archive into an existing backup directory."], ["openclaw backup create --dry-run --json", "Preview the archive plan without writing any files."], ["openclaw backup create --verify", "Create the archive and immediately validate its manifest and payload layout."], ["openclaw backup create --no-include-workspace", "Back up state/config without agent workspace files."], ["openclaw backup create --only-config", "Back up only the active JSON config file."] ])}`).action(async (opts) => { await runCommandWithRuntime(defaultRuntime, async () => { await backupCreateCommand(defaultRuntime, { output: opts.output, json: Boolean(opts.json), dryRun: Boolean(opts.dryRun), verify: Boolean(opts.verify), onlyConfig: Boolean(opts.onlyConfig), includeWorkspace: opts.includeWorkspace }); }); }); backup.command("verify <archive>").description("Validate a backup archive and its embedded manifest").option("--json", "Output JSON", false).addHelpText("after", () => `\n${theme.heading("Examples:")}\n${formatHelpExamples([["openclaw backup verify ./2026-03-09T08-00-00.000+08-00-openclaw-backup.tar.gz", "Check that the archive structure and manifest are intact."], ["openclaw backup verify ~/Backups/latest.tar.gz --json", "Emit machine-readable verification output."]])}`).action(async (archive, opts) => { await runCommandWithRuntime(defaultRuntime, async () => { await backupVerifyCommand(defaultRuntime, { archive, json: Boolean(opts.json) }); }); }); } //#endregion export { registerBackupCommand };