Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
feat(backup): add Run Backup Now button and default exclusions to settings
[._.]/ Adam Eivy15af811ffd7c
diff --git a/client/src/components/settings/BackupTab.jsx b/client/src/components/settings/BackupTab.jsxindex 2002094b84..81f0a58931 100644--- a/client/src/components/settings/BackupTab.jsx+++ b/client/src/components/settings/BackupTab.jsx@@ -1,8 +1,9 @@import { useState, useEffect } from 'react';-import { Save, Plus, X } from 'lucide-react';+import { Save, Plus, X, Play, ShieldOff } from 'lucide-react';import toast from '../ui/Toast';import BrailleSpinner from '../BrailleSpinner';-import { getSettings, updateSettings } from '../../services/api';+import useAsyncAction from '../../hooks/useAsyncAction';+import { getSettings, updateSettings, getBackupStatus, triggerBackup } from '../../services/api';export function BackupTab() {const [loading, setLoading] = useState(true);@@ -11,16 +12,18 @@ export function BackupTab() {const [enabled, setEnabled] = useState(false);const [cronExpression, setCronExpression] = useState('0 2 * * *');const [excludePaths, setExcludePaths] = useState([]);+ const [defaultExcludes, setDefaultExcludes] = useState([]);const [newExclude, setNewExclude] = useState('');useEffect(() => {- getSettings()- .then(settings => {+ Promise.all([getSettings(), getBackupStatus().catch(() => null)])+ .then(([settings, status]) => {const backup = settings?.backup || {};setDestPath(backup.destPath || '');setEnabled(backup.enabled ?? false);setCronExpression(backup.cronExpression || '0 2 * * *');setExcludePaths(backup.excludePaths || []);+ setDefaultExcludes(status?.defaultExcludes || []);}).catch(() => toast.error('Failed to load settings')).finally(() => setLoading(false));@@ -38,6 +41,16 @@ export function BackupTab() {}};+ const [handleRunNow, running] = useAsyncAction(async () => {+ const result = await triggerBackup();+ if (result?.skipped) {+ toast('Backup already running');+ } else {+ toast.success(`Backup complete — ${result?.filesChanged ?? 0} files changed`, { icon: '💾' });+ }+ return result;+ }, { errorMessage: 'Backup failed' });+const addExclude = () => {const trimmed = newExclude.trim();if (!trimmed || excludePaths.includes(trimmed)) return;@@ -53,6 +66,8 @@ export function BackupTab() {return <BrailleSpinner text="Loading backup settings" />;}+ const canRun = !!destPath && !running;+return (<div className="bg-port-card border border-port-border rounded-xl p-4 sm:p-6 space-y-5"><div className="space-y-1">@@ -88,9 +103,27 @@ export function BackupTab() {<p className="text-xs text-gray-500">Default: 2:00 AM daily</p></div>+ {defaultExcludes.length > 0 && (+ <div className="space-y-2">+ <div className="flex items-center gap-2">+ <ShieldOff size={14} className="text-gray-500" />+ <label className="block text-sm text-gray-400">Default Exclusions (always skipped)</label>+ </div>+ <p className="text-xs text-gray-500">Built-in paths that are never backed up — they hold large or ephemeral data that would bloat snapshots.</p>+ <ul className="space-y-1 mt-1">+ {defaultExcludes.map((d, i) => (+ <li key={i} className="flex items-start gap-2 text-xs">+ <code className="px-1.5 py-0.5 bg-port-bg border border-port-border rounded text-gray-300 shrink-0">{d.path}</code>+ <span className="text-gray-500">{d.reason}</span>+ </li>+ ))}+ </ul>+ </div>+ )}+<div className="space-y-2">- <label className="block text-sm text-gray-400">Exclude Paths</label>- <p className="text-xs text-gray-500">Directories/patterns to skip during backup (relative to data/)</p>+ <label className="block text-sm text-gray-400">Additional Exclude Paths</label>+ <p className="text-xs text-gray-500">Custom directories/patterns to skip during backup (relative to data/)</p><div className="flex gap-2"><inputtype="text"@@ -123,14 +156,25 @@ export function BackupTab() {)}</div>- <button- onClick={handleSave}- disabled={saving}- className="inline-flex items-center justify-center gap-2 min-h-[40px] px-4 py-2 bg-port-accent hover:bg-port-accent/80 text-white text-sm font-medium rounded-lg transition-colors disabled:opacity-50"- >- {saving ? <BrailleSpinner /> : <Save size={16} />}- Save- </button>+ <div className="flex flex-wrap items-center gap-2 pt-2 border-t border-port-border">+ <button+ onClick={handleSave}+ disabled={saving}+ className="inline-flex items-center justify-center gap-2 min-h-[40px] px-4 py-2 bg-port-accent hover:bg-port-accent/80 text-white text-sm font-medium rounded-lg transition-colors disabled:opacity-50"+ >+ {saving ? <BrailleSpinner /> : <Save size={16} />}+ Save+ </button>+ <button+ onClick={handleRunNow}+ disabled={!canRun}+ title={destPath ? 'Run a backup snapshot now using saved settings' : 'Configure a destination path first'}+ className="inline-flex items-center justify-center gap-2 min-h-[40px] px-4 py-2 bg-port-border hover:bg-port-border/70 text-white text-sm font-medium rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed"+ >+ {running ? <BrailleSpinner /> : <Play size={16} />}+ {running ? 'Running…' : 'Run Backup Now'}+ </button>+ </div></div>);}diff --git a/server/routes/backup.js b/server/routes/backup.jsindex 85d36e6ac0..5f0ecc00ce 100644--- a/server/routes/backup.js+++ b/server/routes/backup.js@@ -11,7 +11,12 @@ router.get('/status', asyncHandler(async (req, res) => {const state = await backup.getState();const settings = await getSettings();const nextRun = backup.getNextRunTime();- res.json({ ...state, destPath: settings.backup?.destPath ?? null, nextRun });+ res.json({+ ...state,+ destPath: settings.backup?.destPath ?? null,+ nextRun,+ defaultExcludes: backup.DEFAULT_EXCLUDES+ });}));// POST /api/backup/rundiff --git a/server/routes/backup.test.js b/server/routes/backup.test.jsindex 622eead7fa..5b5b9d29e8 100644--- a/server/routes/backup.test.js+++ b/server/routes/backup.test.js@@ -8,7 +8,8 @@ vi.mock('../services/backup.js', () => ({getNextRunTime: vi.fn(),runBackup: vi.fn(),listSnapshots: vi.fn(),- restoreSnapshot: vi.fn()+ restoreSnapshot: vi.fn(),+ DEFAULT_EXCLUDES: [{ path: 'browser-profile/', reason: 'test' }]}));vi.mock('../services/settings.js', () => ({@@ -44,7 +45,8 @@ describe('backup routes', () => {lastRun: '2026-04-01T00:00:00Z',success: true,destPath: '/backup/target',- nextRun: '2026-04-08T00:00:00Z'+ nextRun: '2026-04-08T00:00:00Z',+ defaultExcludes: [{ path: 'browser-profile/', reason: 'test' }]});});diff --git a/server/services/backup.js b/server/services/backup.jsindex dc96c35518..3ab95a161b 100644--- a/server/services/backup.js+++ b/server/services/backup.js@@ -21,6 +21,16 @@ let isRunning = false;const STATE_PATH = join(PATHS.data, 'backup', 'state.json');+// Paths under data/ that are always skipped on top of user-configured excludes.+// Browser profile is a CDP cache that can grow to several GB; worktrees are+// throwaway agent checkouts of the main repo.+export const DEFAULT_EXCLUDES = [+ { path: 'browser-profile/', reason: 'Browser CDP profile — cache/cookies, can be several GB' },+ { path: 'cos/worktrees/', reason: 'Ephemeral agent git worktrees — recreated on demand' }+];++const DEFAULT_EXCLUDE_PATHS = DEFAULT_EXCLUDES.map(e => e.path);+// Snapshots live under snapshots/<hostname>/<snapshotId> so a single shared// destination (e.g. iCloud) can host backups from multiple machines without// their snapshot IDs colliding.@@ -106,7 +116,11 @@ export async function runBackup(destPath, io = null, { excludePaths = [] } = {})const snapshotDir = join(destPath, 'snapshots', MACHINE_HOST, snapshotId);const dataDestDir = join(snapshotDir, 'data');- console.log(`💾 Backup starting: snapshot ${snapshotId}${excludePaths.length ? ` (excluding ${excludePaths.length} paths)` : ''}`);+ // Merge user excludes with built-in defaults; dedupe so user can't double-list a default.+ const userExcludes = excludePaths.filter(Boolean);+ const effectiveExcludes = [...new Set([...DEFAULT_EXCLUDE_PATHS, ...userExcludes])];++ console.log(`💾 Backup starting: snapshot ${snapshotId} (excluding ${effectiveExcludes.length} paths)`);if (io) io.emit('backup:started', { snapshotId });await ensureDir(dataDestDir);@@ -125,7 +139,7 @@ export async function runBackup(destPath, io = null, { excludePaths = [] } = {})throw err;};- const excludeFlags = excludePaths.filter(Boolean).flatMap(p => ['--exclude', p]);+ const excludeFlags = effectiveExcludes.flatMap(p => ['--exclude', p]);changedFiles = await runRsync(PATHS.data, dataDestDir, excludeFlags).catch(fail);console.log(`💾 Backup rsync complete: ${changedFiles.length} files changed (exit 0)`);