MCBDSHost - Professional Minecraft Bedrock Server Management

Backup UI Integration

Client Applications BACKUP_UI_INTEGRATION.md

Backup UI Integration - Complete Implementation

What Was Implemented

1. API Endpoints

BackupController now includes:

  • GET /api/backup/config - Get current backup configuration
  • PUT /api/backup/config - Update backup configuration (saves to appsettings.json)
  • POST /api/backup/trigger - Trigger manual backup immediately
  • GET /api/backup/list - List all existing backups with details
  • DELETE /api/backup/{name} - Delete a specific backup

2. BackupHostedService Enhancement

  • Added TriggerManualBackupAsync() public method
  • Added semaphore to prevent concurrent backups
  • Manual backups can now be triggered without waiting for the schedule

3. BedrockApiService Updates

Added methods for backup management:

- GetBackupConfigAsync()
- UpdateBackupConfigAsync(frequency, directory, maxBackups)
- TriggerManualBackupAsync()
- GetBackupListAsync()
- DeleteBackupAsync(backupName)

4. PublicUI - Backup Settings Page

Complete overhaul of the Backup Settings page with:

Configuration Management:

  • Load settings from API on page load
  • Edit frequency (1-1440 minutes)
  • Edit backup directory path
  • Edit max backups to keep (0 = unlimited)
  • Save settings to API (updates appsettings.json)
  • Restart warning after saving settings

Manual Backup:

  • "Backup Now" button to trigger immediate backup
  • Status feedback during backup operation
  • Auto-refresh backup list after manual backup

Backup Management:

  • View list of existing backups
  • Display name, creation date, and size
  • Refresh button to reload backup list
  • Delete individual backups with confirmation

User Experience:

  • Loading indicators for all operations
  • Status messages with color coding
  • Disabled buttons during operations
  • Helpful information section
  • Current settings display

UI Features

Backup Configuration Card


 Backup Configuration                
                                     
 Backup Frequency: [30] minutes     
 Output Directory: [C:\Backups\...] 
 Maximum Backups:  [10]              
                                     
 [Save Settings]                     
 [Backup Now]                        

Existing Backups Card


 Existing Backups          [Refresh] 
                                     
 Name              Created    Size   
 backup_2025...    Jan 15    45.3MB 
 backup_2025...    Jan 15    44.9MB 
                                     
 Total: 2 backup(s)                  

User Workflow

Edit Settings

  1. User opens Backup Settings page
  2. Settings are loaded from API
  3. User edits frequency, directory, or max backups
  4. User clicks "Save Settings"
  5. Settings are saved to appsettings.json
  6. UI shows success message with restart warning

Trigger Manual Backup

  1. User clicks "Backup Now" button
  2. API triggers BackupHostedService.TriggerManualBackupAsync()
  3. Backup process runs in background
  4. UI shows status message
  5. Backup list auto-refreshes after 3 seconds

View Backups

  1. User views existing backups in table
  2. Can see name, creation date, and size
  3. Click "Refresh" to reload list
  4. Click "Delete" to remove a backup (with confirmation)

Technical Details

Configuration Update Flow

PublicUI
   (PUT /api/backup/config)
BackupController
   (Update file)
appsettings.json
   (Restart required)
BackupHostedService (reads new config)

Manual Backup Flow

User clicks "Backup Now"
  
BedrockApiService.TriggerManualBackupAsync()
   (POST /api/backup/trigger)
BackupController
  
BackupHostedService.TriggerManualBackupAsync()
   (Semaphore prevents concurrent backups)
PerformBackupAsync()
  
Backup created

Concurrency Protection

The semaphore ensures:

  • Only one backup runs at a time
  • Manual backups don't conflict with scheduled backups
  • Returns false if backup already in progress

API Response Examples

GET /api/backup/config

Response:

{
  "frequencyMinutes": 30,
  "backupDirectory": "C:\\Backups\\Minecraft",
  "maxBackupsToKeep": 10
}

PUT /api/backup/config

Request:

{
  "frequencyMinutes": 60,
  "backupDirectory": "D:\\ServerBackups",
  "maxBackupsToKeep": 20
}

Response:

{
  "message": "Configuration updated successfully. Restart the API for changes to take effect.",
  "restartRequired": true,
  "config": {
    "frequencyMinutes": 60,
    "backupDirectory": "D:\\ServerBackups",
    "maxBackupsToKeep": 20
  }
}

POST /api/backup/trigger

Response (Success):

{
  "message": "Manual backup has been triggered successfully.",
  "note": "Check the API logs for backup progress and completion."
}

Response (Already Running):

{
  "error": "A backup is already in progress",
  "message": "Please wait for the current backup to complete before triggering another."
}

GET /api/backup/list

Response:

{
  "backups": [
    {
      "name": "backup_2025-01-15_14-30-00",
      "createdAt": "2025-01-15T14:30:00",
      "sizeMB": 45.3,
      "path": "C:\\Backups\\Minecraft\\backup_2025-01-15_14-30-00"
    },
    {
      "name": "backup_2025-01-15_14-00-00",
      "createdAt": "2025-01-15T14:00:00",
      "sizeMB": 44.9,
      "path": "C:\\Backups\\Minecraft\\backup_2025-01-15_14-00-00"
    }
  ],
  "count": 2
}

DELETE /api/backup/

Response:

{
  "message": "Backup 'backup_2025-01-15_14-00-00' deleted successfully"
}

Important Notes

Restart Required

After updating configuration via the UI:

  1. Settings are saved to appsettings.json
  2. The API must be restarted for changes to take effect
  3. The UI displays a clear warning about this

Validation

All settings are validated:

  • Frequency: 1-1440 minutes
  • Directory: Must not be empty
  • Max Backups: 0 or greater (0 = unlimited)

Security

  • Backup name validation prevents directory traversal attacks
  • No arbitrary file system access
  • Confirmation required before deleting backups

Use Cases

Use Case 1: Admin Changes Backup Frequency

  1. Admin opens PublicUI
  2. Navigates to Backup Settings
  3. Changes frequency from 30 to 60 minutes
  4. Clicks "Save Settings"
  5. Sees success message with restart warning
  6. Restarts API
  7. Backups now run every 60 minutes

Use Case 2: Manual Backup Before Maintenance

  1. Admin needs to perform maintenance
  2. Opens Backup Settings
  3. Clicks "Backup Now"
  4. Waits for confirmation message
  5. Proceeds with maintenance knowing data is backed up

Use Case 3: Clean Up Old Backups

  1. Admin checks disk space
  2. Opens Backup Settings
  3. Views list of backups with sizes
  4. Deletes old backups individually
  5. Or changes "Max Backups to Keep" to auto-clean

Future Enhancements

Potential additions:

  • Download backup as ZIP
  • Restore from backup via UI
  • Backup verification status
  • Scheduled backup calendar view
  • Email notifications
  • Backup to cloud storage

Build Status

Build: Successful
All features: Implemented and tested
Ready for: Production use

Summary

The Backup Settings page in PublicUI is now fully integrated with the API, allowing complete management of backup configuration and operations:

  • View and edit all backup settings
  • Trigger manual backups on demand
  • View existing backups with details
  • Delete individual backups
  • All operations with proper feedback
  • Clean, intuitive user interface

No more manual editing of appsettings.json - everything can be managed through the UI!

Support MCBDSHost Development

Help us continue developing and improving MCBDSHost. Your support makes a difference!