feat: add Network Backup section to Database Management

PC2 can now automatically pull and restore a fresh copy of PC1's database
on a daily schedule. Config and API key are stored in local JSON files so
they survive database restores.

- New networkSyncConfigService: file-based config (network-backup-key.json,
  network-sync-config.json) that persists through DB restores
- New networkSyncService: streams live pg_dump from source PC over HTTP and
  pipes into psql, then reconnects Prisma and applies missing migrations
- 6 new endpoints: get/regenerate API key, serve backup stream (key-auth
  only), get/save sync config, trigger immediate sync
- Hourly cron job that fires only when current hour matches configured syncHour
- NetworkBackupManager component: shows this machine's key (show/copy/regen)
  and receiver config (enable toggle, hour picker 0-23, source URL + key,
  Save + Sync Now, last sync status)
- README setup guide for both PCs

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
ff
2026-06-09 00:15:42 -04:00
co-authored by Claude Sonnet 4.6
parent 27d95ed752
commit f5f3768108
8 changed files with 668 additions and 1 deletions
@@ -14,6 +14,7 @@ import { useMutation, useQuery } from "@tanstack/react-query";
import { apiRequest, queryClient } from "@/lib/queryClient";
import { formatDateToHumanReadable } from "@/utils/dateUtils";
import { BackupDestinationManager } from "@/components/database-management/backup-destination-manager";
import { NetworkBackupManager } from "@/components/database-management/network-backup-manager";
import { ImportDatabaseSection } from "@/components/database-management/import-database-section";
export default function DatabaseManagementPage() {
@@ -261,6 +262,9 @@ export default function DatabaseManagementPage() {
{/* Externa Drive automatic backup manager */}
<BackupDestinationManager />
{/* Network Backup (PC-to-PC sync) */}
<NetworkBackupManager />
{/* Import / Restore Database */}
<ImportDatabaseSection />