feat: automatisches SSH-Backup nach jedem Logbuch-Eintrag
Nach jedem POST und PUT im Logbuch wird mysqldump (ohne beos-Tabelle) via gzip | ssh auf einen externen Server übertragen. Backups älter als 30 Tage werden automatisch gelöscht. BACKUP_SSH_URL und BACKUP_SSH_KEY_PATH in .env konfigurieren; SSH-Key als Volume mounten. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
import { query, getPool } from '@/lib/db';
|
||||
import { getSession } from '@/lib/session';
|
||||
import { triggerBackup } from '@/lib/backup';
|
||||
import type { SelectedObjekt } from '@/types/logbuch';
|
||||
|
||||
export async function PUT(request: NextRequest, { params }: { params: Promise<{ id: string }> }) {
|
||||
@@ -68,6 +69,7 @@ export async function PUT(request: NextRequest, { params }: { params: Promise<{
|
||||
);
|
||||
}
|
||||
|
||||
triggerBackup();
|
||||
return NextResponse.json({ ok: true });
|
||||
} catch (error) {
|
||||
console.error('PUT /api/logbuch/[id]:', error);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
import { query, getPool } from '@/lib/db';
|
||||
import { getSession } from '@/lib/session';
|
||||
import { triggerBackup } from '@/lib/backup';
|
||||
import type { SelectedObjekt } from '@/types/logbuch';
|
||||
|
||||
const LIST_SQL =
|
||||
@@ -137,6 +138,7 @@ export async function POST(request: NextRequest) {
|
||||
);
|
||||
}
|
||||
|
||||
triggerBackup();
|
||||
return NextResponse.json({ id: logbuchId }, { status: 201 });
|
||||
} catch (error) {
|
||||
console.error('POST /api/logbuch:', error);
|
||||
|
||||
Reference in New Issue
Block a user