📋 Description

This PR implements backup capabilities for PostgreSQL databases using pgBackRest, addressing the limitations of the current pg_dump-based backup system, particularly for large databases.

🎯 Changes Made

Core Components

1. New Service Layer (app/Services/PgBackRestService.php)

  • Handles all pgBackRest operations
  • Automatic installation in database containers
  • Configuration management (stanza creation, WAL archiving)
  • Backup operations (full, differential, incremental)
  • Restore operations (full database and PITR)
  • S3 integration with encryption
  • Status monitoring and health checks

2. Background Job (app/Jobs/PgBackRestBackupJob.php)

  • Queue-based backup execution
  • Intelligent backup type selection:
    • Full backup: Every 7 days
    • Differential backup: Daily (changes since last full)
    • Incremental backup: All other times (changes since last backup)
  • Automatic retention management
  • Error handling and notifications
  • Integration with existing backup system

3. Database Schema (database/migrations/_add_pgbackrest_support.php)

  • Added backup_engine field to scheduled_database_backups (pg_dump/pgbackrest)
  • Added use_pgbackrest boolean flag
  • Added pgbackrest_config JSON field for configuration
  • Added backup_type to scheduled_database_backup_executions (full/diff/incr)
  • Added database_size to track original database size
  • New pgbackrest_configurations table for detailed status tracking
  • All changes maintain backward compatibility

4. UI Components

  • Livewire Component (app/Livewire/Project/Database/Backup/BackupConfiguration.php)

    • Enable/disable pgBackRest with one click
    • Real-time status indicators
    • Configuration management
    • Manual backup triggers
  • Blade View (resources/views/livewire/project/database/backup/configuration.blade.php)

    • Beautiful, modern interface
    • Dark mode support
    • Cost savings indicators
    • Backup strategy explanation
    • One-click actions

5. API Endpoints (app/Http/Controllers/Api/BackupController.php)

  • GET /api/databases/{uuid}/backups - List all backups
  • POST /api/databases/{uuid}/backups - Create backup configuration
  • POST /api/backups/{id}/execute - Trigger manual backup (with optional type)
  • GET /api/backups/executions/{id} - Get execution details
  • POST /api/backups/executions/{id}/restore - Restore from backup (with optional PITR)
  • GET /api/databases/{uuid}/pgbackrest/status - Get pgBackRest status

🔗 Related Issues

Closes #7172

/claim #7172

Claim

Total prize pool $500
Total paid $0
Status Pending
Submitted November 13, 2025
Last updated November 13, 2025

Contributors

JO

Joshua Kelechi

@jaykayudo

100%

Sponsors

ZA

Zach Latta

@zachlatta

$500