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

Backupbundle Laravel Package

edemy/backupbundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Steps

  1. Installation

    composer require edemy/backupbundle
    

    Ensure eDemyFramework is installed (this bundle is framework-specific).

  2. Configuration Add the bundle to config/bundles.php:

    return [
        // ...
        Edemy\BackupBundle\EdemyBackupBundle::class => ['all' => true],
    ];
    
  3. Basic Usage Define a backup job in config/backup.php:

    jobs:
        default:
            type: 'filesystem'
            path: '%kernel.project_dir%/var/backups'
            files:
                - '%kernel.project_dir%/app'
                - '%kernel.project_dir%/var/logs'
    
  4. First Run Trigger a backup via CLI:

    php bin/console edemy:backup:run default
    

Where to Look First

  • Configuration: config/backup.php (primary config file).
  • Commands: bin/console edemy:backup: (list available commands).
  • Events: Edemy\BackupBundle\Event\BackupEvents (for custom logic).

Implementation Patterns

Common Workflows

  1. Scheduled Backups Use Symfony’s CronBundle or Laravel Scheduler (if hybrid) to automate:

    # config/packages/cron.yaml
    cron:
        jobs:
            daily_backup:
                command: 'edemy:backup:run default'
                schedule: '0 2 * * *'
    
  2. Conditional Backups Extend the BackupJob class to add logic (e.g., skip if DB is locked):

    // src/Backup/CustomJob.php
    namespace App\Backup;
    
    use Edemy\BackupBundle\Job\BackupJob;
    
    class CustomJob extends BackupJob {
        protected function shouldRun(): bool {
            return !\DB::connection()->getPdo()->inTransaction();
        }
    }
    
  3. Multi-Environment Backups Override path in backup.php per environment:

    # config/backup.php (prod)
    jobs:
        prod:
            path: '/mnt/backups/prod'
    
  4. Post-Backup Actions Listen to BackupEvents::POST_BACKUP to notify Slack/email:

    // src/EventListener/BackupListener.php
    namespace App\EventListener;
    
    use Edemy\BackupBundle\Event\BackupEvents;
    use Symfony\Component\EventDispatcher\EventSubscriberInterface;
    
    class BackupListener implements EventSubscriberInterface {
        public static function getSubscribedEvents() {
            return [
                BackupEvents::POST_BACKUP => 'onBackupComplete',
            ];
        }
    
        public function onBackupComplete() {
            // Send notification
        }
    }
    

Integration Tips

  • Laravel Hybrid: Use symfony/console bridge if mixing frameworks:
    use Symfony\Component\Console\Application;
    $app = new Application();
    $app->add(new \Edemy\BackupBundle\Command\BackupCommand());
    
  • Storage Adapters: Extend Edemy\BackupBundle\Storage\StorageInterface for S3/Cloud storage.
  • Logging: Pipe backup logs to monolog via BackupEvents::PRE_BACKUP.

Gotchas and Tips

Pitfalls

  1. Framework Lock-in

    • Bundle is eDemy-specific; avoid if using vanilla Laravel.
    • Workaround: Fork and adapt for Laravel’s Artisan or use spatie/laravel-backup.
  2. Permission Issues

    • Ensure path in backup.php is writable by the web server:
      chmod -R 775 %kernel.project_dir%/var/backups
      
    • Tip: Use absolute paths (e.g., /var/backups/app) to avoid symlink confusion.
  3. Missing Events

    • No PRE_BACKUP event in early versions; patch or extend:
      // src/Event/PreBackupEvent.php
      namespace App\Event;
      use Edemy\BackupBundle\Event\BackupEvents;
      class PreBackupEvent extends \Symfony\Contracts\EventDispatcher\Event {}
      
  4. Database Backups

Debugging

  • Dry Runs: Add dry_run: true to backup.php to test without writing files.
  • Verbose Mode: Run with -vvv for detailed logs:
    php bin/console edemy:backup:run default -vvv
    
  • Storage Errors: Check StorageInterface implementations for custom logic quirks.

Extension Points

  1. Custom Storage Implement Edemy\BackupBundle\Storage\StorageInterface for S3/Google Drive:

    class S3Storage implements StorageInterface {
        public function save(string $path, string $content): bool {
            // Use AWS SDK
        }
    }
    
  2. Job Factories Override Edemy\BackupBundle\Factory\BackupJobFactory to add pre/post hooks.

  3. Notification Channels Extend Edemy\BackupBundle\Notifier\NotifierInterface for custom alerts (e.g., Telegram).

Pro Tips

  • Exclude Files: Use .backupignore (like .gitignore) in the backup root.
  • Compression: Add compression: true to backup.php for .zip outputs.
  • Retention Policy: Use cron + find to auto-delete old backups:
    find /var/backups -type f -mtime +30 -delete
    
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.
calmfox/watch-sylius
damienfern/grpc-symfony-bundle
atoolo/index-bundle
atoolo/genai-bundle
coprotoai/laravel-ticket
davidjln/llm-carbon-bundle
cryonighter/valid-request-bundle
coolms/taxonomy-bundle
coolms/field-bundle
articulate-orm/symfony
aaix/laravel-tall-architect
ephoto/akeneo-connector
emmanuelballery/eb-plantumlbundle
emielburgman/symfony-visitor-beacon
emielburgman/symfony-visit-storage
emielburgman/symfony-security-headers
emielburgman/symfony-log-viewer
emarref/xdebug-bundle
emarref/pubnub-bundle
elriseio/finance-money-bundle