Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Backup Ui Laravel Package

xatta-trone/laravel-backup-ui

View on GitHub
Deep Wiki
Context7

Getting Started

First Steps

  1. Installation

    composer require xatta-trone/laravel-backup-ui
    php artisan vendor:publish --provider="XattaTrone\BackupUI\BackupUIServiceProvider" --tag="migrations"
    php artisan migrate
    
    • Publish the config (php artisan vendor:publish --provider="XattaTrone\BackupUI\BackupUIServiceProvider" --tag="config") if customization is needed.
  2. Configuration

    • Edit config/backup-ui.php to define backup sources (e.g., databases, files, directories).
    • Example minimal config:
      'sources' => [
          'database' => [
              'type' => 'database',
              'name' => 'main_db',
              'connection' => 'mysql',
          ],
          'files' => [
              'type' => 'files',
              'path' => storage_path('app'),
          ],
      ],
      
  3. First Use Case

    • Run a backup manually:
      php artisan backup:run
      
    • Access the UI at /backup-ui (default route) to view, download, or restore backups.

Implementation Patterns

Core Workflows

  1. Backup Scheduling

    • Use Laravel’s task scheduling (app/Console/Kernel.php) to automate backups:
      $schedule->command('backup:run')->dailyAt('2:00');
      
    • Customize frequency via config/backup-ui.php:
      'schedule' => [
          'frequency' => 'daily',
          'retention_days' => 7,
      ],
      
  2. Dynamic Backup Sources

    • Extend backup sources by creating custom classes (e.g., for APIs or cloud storage):
      namespace App\Backups;
      
      use XattaTrone\BackupUI\Contracts\BackupSource;
      
      class CustomSource implements BackupSource {
          public function backup() { ... }
          public function restore() { ... }
      }
      
    • Register in config/backup-ui.php:
      'sources' => [
          'custom' => [
              'type' => 'custom',
              'class' => \App\Backups\CustomSource::class,
          ],
      ],
      
  3. UI Integration

    • Customize the dashboard by publishing views:
      php artisan vendor:publish --provider="XattaTrone\BackupUI\BackupUIServiceProvider" --tag="views"
      
    • Override templates in resources/views/vendor/backup-ui/.
  4. Storage Backends

    • Configure storage drivers (e.g., S3, FTP) in config/backup-ui.php:
      'storage' => [
          'driver' => 's3',
          'config' => [
              'key' => env('AWS_ACCESS_KEY_ID'),
              'secret' => env('AWS_SECRET_ACCESS_KEY'),
              'bucket' => 'my-backups',
          ],
      ],
      

Gotchas and Tips

Common Pitfalls

  1. Permission Issues

    • Ensure the backup user has write access to storage paths (e.g., storage/backups).
    • For S3/FTP, verify credentials and bucket permissions.
  2. Large File Handling

    • Backups may fail if files exceed PHP’s upload_max_filesize or post_max_size.
    • Split backups into chunks or use streaming:
      'chunk_size' => 1024 * 1024 * 50, // 50MB chunks
      
  3. Database-Specific Quirks

    • MySQL/MariaDB: Lock tables during backup to avoid corruption:
      'database' => [
          'lock_tables' => true,
      ],
      
    • PostgreSQL: Use pg_dump with --clean for schema-only backups.
  4. Retention Policy Gaps

    • Default retention deletes old backups automatically. Override in config:
      'retention' => [
          'keep' => 30, // Keep 30 backups
          'strategy' => 'oldest-first', // or 'newest-first'
      ],
      

Debugging Tips

  • Log Backups: Enable logging in config/backup-ui.php:

    'logging' => true,
    

    Check logs at storage/logs/laravel.log.

  • Dry Runs: Test backups without saving:

    php artisan backup:run --dry-run
    
  • Manual Triggers: Debug failed backups by running commands manually:

    php artisan backup:run --source=database
    

Extension Points

  1. Custom Notifications

    • Extend the BackupCompleted event to send alerts (e.g., Slack, Email):
      use XattaTrone\BackupUI\Events\BackupCompleted;
      
      BackupCompleted::dispatch($backup)->listen(function ($event) {
          // Send notification logic
      });
      
  2. Pre/Post Backup Hooks

    • Use service providers to hook into backup lifecycle:
      public function boot()
      {
          BackupUI::preBackup(function ($backup) {
              // Pre-backup logic (e.g., flush caches)
          });
      
          BackupUI::postBackup(function ($backup) {
              // Post-backup logic (e.g., cleanup)
          });
      }
      
  3. API Access

    • Expose backup endpoints via Laravel routes:
      Route::middleware('auth')->group(function () {
          Route::get('/api/backups', [BackupController::class, 'index']);
      });
      
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
nasirkhan/laravel-sharekit
directorytree/privacy-filter-classifier
directorytree/privacy-filter
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata
splash/openapi
splash/scopes
splash/toolkit
testo/output-teamcity
testo/bridge-symfony