feat(backup): add MinIO snapshot backups via CLI and scheduler

This commit is contained in:
William Valentin
2026-02-16 13:16:29 -08:00
parent 8bed99c770
commit 01ee6ba53f
13 changed files with 416 additions and 1 deletions
+1 -1
View File
@@ -1,3 +1,3 @@
export { loadConfig, deepMerge } from './loader.js';
export { persistConfig } from './persistence.js';
export { configSchema, MODEL_PROVIDERS, type ModelProvider, type Config, type TelegramConfig, type ModelConfig, type CronJobConfig, type AgentsConfig, type CompactionConfig, type ToolProfile, type ToolOverrideConfig, type ToolsConfig, type SandboxConfig, type AgentConfigEntry, type RoutingConfig, type ServerConfig } from './schema.js';
export { configSchema, MODEL_PROVIDERS, type ModelProvider, type Config, type TelegramConfig, type ModelConfig, type CronJobConfig, type AgentsConfig, type CompactionConfig, type ToolProfile, type ToolOverrideConfig, type ToolsConfig, type SandboxConfig, type AgentConfigEntry, type RoutingConfig, type ServerConfig, type BackupConfig } from './schema.js';
+48
View File
@@ -196,6 +196,54 @@ describe('configSchema — server', () => {
});
});
describe('configSchema — backup', () => {
const minimalConfig = {
telegram: { bot_token: 'test', allowed_chat_ids: [1] },
models: { default: { provider: 'anthropic', model: 'claude-3' } },
};
it('defaults backup settings', () => {
const result = configSchema.parse(minimalConfig);
expect(result.backup.enabled).toBe(false);
expect(result.backup.interval).toBe('24h');
expect(result.backup.include_vectors).toBe(true);
expect(result.backup.minio.enabled).toBe(false);
expect(result.backup.minio.prefix).toBe('flynn');
expect(result.backup.minio.secure).toBe(true);
});
it('accepts custom backup settings', () => {
const result = configSchema.parse({
...minimalConfig,
backup: {
enabled: true,
interval: '12h',
local_dir: '/tmp/flynn-backups',
include_vectors: false,
minio: {
enabled: true,
endpoint: 'localhost:9000',
access_key: 'key',
secret_key: 'secret',
bucket: 'flynn-backups',
prefix: 'daily',
secure: false,
},
},
});
expect(result.backup.enabled).toBe(true);
expect(result.backup.interval).toBe('12h');
expect(result.backup.local_dir).toBe('/tmp/flynn-backups');
expect(result.backup.include_vectors).toBe(false);
expect(result.backup.minio.enabled).toBe(true);
expect(result.backup.minio.endpoint).toBe('localhost:9000');
expect(result.backup.minio.bucket).toBe('flynn-backups');
expect(result.backup.minio.prefix).toBe('daily');
expect(result.backup.minio.secure).toBe(false);
});
});
describe('configSchema — agent_configs', () => {
const minimalConfig = {
telegram: { bot_token: 'test', allowed_chat_ids: [1] },
+18
View File
@@ -672,6 +672,22 @@ const sessionsSchema = z.object({
ttl: z.string().default('30d'),
}).default({});
const backupSchema = z.object({
enabled: z.boolean().default(false),
interval: z.string().default('24h'),
local_dir: z.string().default('~/.local/share/flynn/backups'),
include_vectors: z.boolean().default(true),
minio: z.object({
enabled: z.boolean().default(false),
endpoint: z.string().optional(),
access_key: z.string().optional(),
secret_key: z.string().optional(),
bucket: z.string().optional(),
prefix: z.string().default('flynn'),
secure: z.boolean().default(true),
}).default({}),
}).default({});
const historyIndexSchema = z.object({
enabled: z.boolean().default(false),
max_keywords: z.number().min(1).max(20).default(8),
@@ -736,6 +752,7 @@ export const configSchema = z.object({
routing_policy: routingPolicySchema,
history_index: historyIndexSchema,
sessions: sessionsSchema,
backup: backupSchema,
pairing: pairingSchema,
});
@@ -777,6 +794,7 @@ export type RoutingPolicyConfig = z.infer<typeof routingPolicySchema>;
export type HistoryIndexConfig = z.infer<typeof historyIndexSchema>;
export type ServerConfig = z.infer<typeof serverSchema>;
export type SessionsConfig = z.infer<typeof sessionsSchema>;
export type BackupConfig = z.infer<typeof backupSchema>;
export type ThinkingConfig = z.infer<typeof thinkingSchema>;
export type HeartbeatConfig = z.infer<typeof heartbeatSchema>;
export type HeartbeatCheck = z.infer<typeof heartbeatCheckSchema>;