diff --git a/src/components/database/DatabaseBackupTab.tsx b/src/components/database/DatabaseBackupTab.tsx index 75b2139..904e546 100644 --- a/src/components/database/DatabaseBackupTab.tsx +++ b/src/components/database/DatabaseBackupTab.tsx @@ -1,5 +1,5 @@ -import React from 'react'; -import { Database, BookOpen, Download, RefreshCw, CheckCircle, AlertCircle, ShieldCheck } from 'lucide-react'; +import React, { useState } from 'react'; +import { Database, BookOpen, Download, RefreshCw, CheckCircle, AlertCircle, ShieldCheck, Copy, Check } from 'lucide-react'; interface DatabaseBackupTabProps { dbInfo: any | null; @@ -20,6 +20,20 @@ export const DatabaseBackupTab: React.FC = ({ onRefresh, onDownloadBackup, }) => { + const [copiedSnippet, setCopiedSnippet] = useState(false); + + const restoreSnippetText = `# 1. Restore directly via pipeline into Docker or host database: +gunzip -c panaceadb_backup_full_latest.sql.gz | docker exec -i panacea-postgres psql -U postgres -d panaceadb + +# 2. Or uncompress first and inspect the raw SQL statements: +gunzip panaceadb_backup_full_latest.sql.gz +head -n 40 panaceadb_backup_full_latest.sql`; + + const handleCopySnippet = () => { + navigator.clipboard.writeText(restoreSnippetText); + setCopiedSnippet(true); + setTimeout(() => setCopiedSnippet(false), 2000); + }; return (
{/* Top Header Card */} @@ -201,21 +215,47 @@ export const DatabaseBackupTab: React.FC = ({ In the event of a system rebuild or migration, you can restore any downloaded snapshot file directly using standard PostgreSQL CLI utilities:

-
-
# 1. Restore directly via pipeline into Docker or host database:
-
- gunzip -c panaceadb_backup_full_latest.sql.gz | docker exec -i panacea-postgres psql -U postgres -d panaceadb -
-
# 2. Or uncompress first and inspect the raw SQL statements:
-
- gunzip panaceadb_backup_full_latest.sql.gz -
-
- head -n 40 panaceadb_backup_full_latest.sql +
+ {/* Copy Button */} + + +
+
# 1. Restore directly via pipeline into Docker or host database:
+
+ gunzip -c panaceadb_backup_full_latest.sql.gz | docker exec -i panacea-postgres psql -U postgres -d panaceadb +
+
# 2. Or uncompress first and inspect the raw SQL statements:
+
+ gunzip panaceadb_backup_full_latest.sql.gz +
+
+ head -n 40 panaceadb_backup_full_latest.sql +
-
+
PostgreSQL Engine: {dbInfo?.postgres_version || '16.14'} Internal Host: {dbInfo?.host || 'db'}:{dbInfo?.port || 5432}