restore: safe default (no gateway restart) + --restart-gateway flag

This commit is contained in:
2026-03-07 13:24:10 +10:00
parent 400a89a897
commit 7eb9f4ac70
2 changed files with 106 additions and 0 deletions
+17
View File
@@ -2,6 +2,7 @@
import { readFileSync, writeFileSync, copyFileSync, existsSync } from 'node:fs';
import { execFileSync } from 'node:child_process';
import { join } from 'node:path';
import { restoreApply, restoreGuide } from './restore.js';
type Json = any;
@@ -223,6 +224,8 @@ if (!cmd || cmd === 'help' || cmd === '--help' || cmd === '-h') {
console.log(' clawkeeper switch openai|ollama');
console.log(' clawkeeper backup-plan [--json]');
console.log(' clawkeeper verify-backup <path.tgz>');
console.log(' clawkeeper restore-guide');
console.log(' clawkeeper restore-apply <path.tgz>');
process.exit(0);
}
@@ -257,6 +260,20 @@ else if (cmd === 'verify-backup') {
die(`Failed to read tarball: ${e?.message || e}`);
}
}
else if (cmd === 'restore-guide') {
restoreGuide({ home: HOME });
}
else if (cmd === 'restore-apply') {
const file = args[0];
if (!file) die('Usage: clawkeeper restore-apply <path.tgz> [--restart-gateway]');
const restartGateway = args.includes('--restart-gateway');
const tgz = untildify(file);
try {
restoreApply({ home: HOME, tgzPath: tgz, restartGateway });
} catch (e: any) {
die(String(e?.message || e));
}
}
else if (cmd === 'switch') {
const to = args[0];
if (to !== 'openai' && to !== 'ollama') die('Usage: clawkeeper switch openai|ollama');