feat: enhance backup functionality and logging
- Updated `createBackup` method to accept a `force` parameter, allowing backups to be created even if no changes are detected. - Added user alerts in `AdvancedSettingsPageClient` and `BackupSettingsPageClient` for backup status feedback. - Implemented `getBackupLogs` method in `BackupService` to retrieve backup logs, with a new API route for accessing logs. - Enhanced UI in `BackupSettingsPageClient` to display backup logs and provide a refresh option. - Updated `BackupManagerCLI` to support forced backups via command line.
This commit is contained in:
@@ -2,8 +2,21 @@ import { NextRequest, NextResponse } from 'next/server';
|
||||
import { backupService } from '@/services/backup';
|
||||
import { backupScheduler } from '@/services/backup-scheduler';
|
||||
|
||||
export async function GET() {
|
||||
export async function GET(request: NextRequest) {
|
||||
try {
|
||||
const { searchParams } = new URL(request.url);
|
||||
const action = searchParams.get('action');
|
||||
|
||||
if (action === 'logs') {
|
||||
const maxLines = parseInt(searchParams.get('maxLines') || '100');
|
||||
const logs = await backupService.getBackupLogs(maxLines);
|
||||
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
data: { logs }
|
||||
});
|
||||
}
|
||||
|
||||
console.log('🔄 API GET /api/backups called');
|
||||
|
||||
// Test de la configuration d'abord
|
||||
@@ -51,7 +64,17 @@ export async function POST(request: NextRequest) {
|
||||
|
||||
switch (action) {
|
||||
case 'create':
|
||||
const backup = await backupService.createBackup('manual');
|
||||
const forceCreate = params.force === true;
|
||||
const backup = await backupService.createBackup('manual', forceCreate);
|
||||
|
||||
if (backup === null) {
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
skipped: true,
|
||||
message: 'No changes detected since last backup. Use force=true to create anyway.'
|
||||
});
|
||||
}
|
||||
|
||||
return NextResponse.json({ success: true, data: backup });
|
||||
|
||||
case 'verify':
|
||||
|
||||
Reference in New Issue
Block a user