feat: Integrate pgBackRest for PostgreSQL backups#8413
Closed
285729101 wants to merge 1 commit intocoollabsio:v4.xfrom
Closed
feat: Integrate pgBackRest for PostgreSQL backups#8413285729101 wants to merge 1 commit intocoollabsio:v4.xfrom
285729101 wants to merge 1 commit intocoollabsio:v4.xfrom
Conversation
Add pgBackRest as an alternative backup method for PostgreSQL databases,
enabling efficient incremental and differential backups. This is
particularly beneficial for large databases (100GB+) where pg_dump
becomes impractical due to time and storage costs.
Changes:
- Add PgBackRestBackupJob with WAL archiving, stanza management,
and full/differential/incremental backup support
- Add PgBackRestRestoreJob for point-in-time and labeled restores
- Add migration for pgBackRest configuration fields on
scheduled_database_backups table (backup type, retention,
S3/MinIO repo configuration)
- Update BackupEdit Livewire component with pgBackRest UI controls
including backup type selection, retention settings, S3 config,
backup info viewer, and restore button
- Update CreateScheduledBackup to offer pgBackRest option for
PostgreSQL databases
- Update BackupNow to dispatch correct job based on configuration
- Update ScheduledJobManager and RunScheduledJobsManually to
dispatch PgBackRestBackupJob when use_pgbackrest is enabled
- Add API support for pgBackRest fields in backup CRUD endpoints
- Add POST /databases/{uuid}/backups/{id}/restore API endpoint
- Encrypt S3 credentials (pgbackrest_s3_key, pgbackrest_s3_secret)
- Add comprehensive feature tests
Closes coollabsio#7423
Contributor
|
This PR did not pass quality checks so it will be closed. If you believe this is a mistake please let us know. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements pgBackRest integration for PostgreSQL databases in Coolify, addressing the need for efficient incremental backups for large databases (100GB+). This replaces the standard
pg_dumpapproach (when enabled) with pgBackRest's WAL-based backup system, which supports:Changes
New files:
app/Jobs/PgBackRestBackupJob.php- Backup job that installs pgBackRest in the PG container, configures WAL archiving, creates stanzas, and runs full/diff/incr backupsapp/Jobs/PgBackRestRestoreJob.php- Restore job that stops PG, runs pgBackRest delta restore, and restarts the databasedatabase/migrations/2026_02_17_000002_add_pgbackrest_to_scheduled_database_backups.php- Adds pgBackRest config columns (backup type, retention, S3 credentials)tests/Feature/PgBackRestBackupTest.php- Feature tests for migration, model casts, job classes, and API validationModified files:
app/Models/ScheduledDatabaseBackup.php- Added casts for pgBackRest boolean and encrypted S3 credentialsapp/Livewire/Project/Database/BackupEdit.php- Added pgBackRest configuration properties, sync logic, restore action, and info viewerapp/Livewire/Project/Database/BackupNow.php- DispatchesPgBackRestBackupJobwhen pgBackRest is enabledapp/Livewire/Project/Database/CreateScheduledBackup.php- Added pgBackRest toggle for PostgreSQL databasesapp/Jobs/ScheduledJobManager.php- Routes to correct job class based onuse_pgbackrestflagapp/Console/Commands/RunScheduledJobsManually.php- Same routing for manual job dispatchapp/Http/Controllers/Api/DatabasesController.php- Added pgBackRest fields to backup create/update API validation and dispatchroutes/api.php- AddedPOST /databases/{uuid}/backups/{id}/restoreendpointresources/views/livewire/project/database/backup-edit.blade.php- Full pgBackRest UI section with backup type, retention, S3 config, info viewer, and restore buttonresources/views/livewire/project/database/create-scheduled-backup.blade.php- pgBackRest checkbox for PostgreSQLHow it works
Closes #7423
Test plan
🤖 Generated with Claude Code