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

Cloud Backup Bundle Laravel Package

dizda/cloud-backup-bundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation

    composer require dizda/cloud-backup-bundle
    

    Add to config/bundles.php:

    Dizda\CloudBackupBundle\DizdaCloudBackupBundle::class => ['all' => true],
    
  2. Configure Cloud Provider Edit config/packages/dizda_cloud_backup.yaml (or create if missing):

    dizda_cloud_backup:
        cloud:
            service: dropbox  # or cloudapp, s3, googledrive
            # Provider-specific config (e.g., Dropbox API key)
            dropbox:
                app_key: "%env(DROPBOX_APP_KEY)%"
                app_secret: "%env(DROPBOX_APP_SECRET)%"
    
  3. First Backup Command

    php bin/console dizda:cloud-backup:dump --database=mysql --cloud=dropbox
    

    Flags:

    • --database: mysql, mongodb, or postgresql
    • --cloud: Target cloud service
    • --all-databases: Dump all databases (MySQL only)

Where to Look First

  • Configuration: config/packages/dizda_cloud_backup.yaml (or app/config/config.yml in Symfony 2.x).
  • Commands: php bin/console list dizda to see available backup commands.
  • Logging: Check var/log/dev.log for backup execution details.

First Use Case: Scheduled MySQL Backup to Dropbox

  1. Set up environment variables for Dropbox credentials in .env.
  2. Run a test backup:
    php bin/console dizda:cloud-backup:dump --database=mysql --cloud=dropbox --path="/Backups/MyApp"
    
  3. Automate with Cron:
    0 2 * * * cd /path/to/project && php bin/console dizda:cloud-backup:dump --database=mysql --cloud=dropbox --path="/Backups/MyApp" >> /var/log/myapp_backup.log 2>&1
    

Implementation Patterns

Workflow: Multi-Database + Multi-Cloud Backups

  1. Define Backup Profiles in config/packages/dizda_cloud_backup.yaml:
    dizda_cloud_backup:
        backups:
            - name: "production_backup"
              databases:
                  - { type: mysql, host: "127.0.0.1", user: "root", password: "%env(DB_PASSWORD)%" }
                  - { type: mongodb, host: "mongodb://user:pass@localhost:27017" }
              clouds:
                  - { service: dropbox, path: "/Backups/Prod" }
                  - { service: s3, bucket: "my-backups", prefix: "prod/" }
    
  2. Run Profiled Backup:
    php bin/console dizda:cloud-backup:run production_backup
    

Integration Tips

  1. Pre/Post Backup Hooks Override the BackupCommand to add logic before/after backup:

    // src/Command/CustomBackupCommand.php
    namespace App\Command;
    use Dizda\CloudBackupBundle\Command\BackupCommand;
    use Symfony\Component\Console\Input\InputInterface;
    use Symfony\Component\Console\Output\OutputInterface;
    
    class CustomBackupCommand extends BackupCommand {
        protected function execute(InputInterface $input, OutputInterface $output) {
            $this->logPreBackup($output);
            parent::execute($input, $output);
            $this->logPostBackup($output);
        }
    }
    

    Register as a service in config/services.yaml and replace the original command.

  2. Custom Backup Paths Use the --path flag or extend the BackupManager to dynamically generate paths:

    dizda_cloud_backup:
        backup_path: "%kernel.project_dir%/backups/%database%_%date%"
    
  3. Compression Enable gzip compression in config:

    dizda_cloud_backup:
        compression: true
    
  4. Database-Specific Config For PostgreSQL, exclude system databases:

    dizda_cloud_backup:
        databases:
            postgresql:
                exclude: ["template0", "template1", "postgres"]
    

Cloud Provider-Specific Patterns

Provider Key Configuration Notes
Dropbox app_key, app_secret, access_token Use OAuth2 for production.
CloudApp api_key, api_secret Requires CloudApp-API-PHP-wrapper.
S3 bucket, access_key, secret_key Works with KnpGaufretteBundle or OneupFlysystemBundle.
Google Drive client_id, client_secret, refresh_token Use Google API PHP Client.

Gotchas and Tips

Pitfalls

  1. Deprecated Symfony 2.x

    • The bundle is designed for Symfony 2.x (last release: 2017). For Symfony 4/5/6:
      • Use a wrapper or fork (e.g., this community fork).
      • Replace app/config/config.yml with config/packages/dizda_cloud_backup.yaml.
    • Workaround: Install via Composer and manually adapt the bundle structure.
  2. Cloud Provider Dependencies

    • Dropbox: Requires dropbox/dropbox-sdk (auto-installed via Composer).
    • CloudApp: Needs matthiasplappert/cloudapp-api-php-wrapper (not auto-installed). Fix: Add to composer.json:
      "require": {
          "matthiasplappert/cloudapp-api-php-wrapper": "^1.0"
      }
      
    • S3: Requires knplabs/knp-gaufrette-bundle or oneup/flysystem-bundle (not auto-installed).
  3. MongoDB Dump Path Issues

    • If MongoDB dumps fail silently, ensure mongodump is in PATH or specify its location in config:
      dizda_cloud_backup:
          mongodb:
              mongodump_path: "/usr/local/bin/mongodump"
      
  4. Large File Uploads

    • Cloud providers (e.g., Dropbox) may throttle large files (>50MB). Split backups:
      dizda_cloud_backup:
          chunk_size: 20971520  # 20MB chunks
      

Debugging

  1. Enable Verbose Logging

    php bin/console dizda:cloud-backup:dump --verbose --database=mysql --cloud=dropbox
    

    Or configure Monolog in config/packages/monolog.yaml:

    monolog:
        handlers:
            main:
                level: debug
    
  2. Check Backup Files Locally Backups are temporarily stored in var/backups/ before upload. Inspect files here to debug dump failures.

  3. Cloud Provider Errors

    • Dropbox: Check access_token expiration (tokens expire after ~4 hours). Fix: Use a refresh token or implement OAuth2 flow.
    • S3: Verify IAM permissions for the bucket.
    • Google Drive: Ensure refresh_token is valid (tokens expire; regenerate if needed).

Configuration Quirks

  1. Environment Variables Always use %env() for sensitive data (e.g., app_secret):

    dizda_cloud_backup:
        cloud:
            dropbox:
                app_key: "%env(DROPBOX_APP_KEY)%"
    

    Define in .env:

    DROPBOX_APP_KEY=your_key_here
    
  2. Database Connection Issues

    • For remote databases, ensure the Laravel/Symfony app can connect:
      dizda_cloud_backup:
          databases:
              mysql:
                  host: "remote-db.example.com"
                  port: 3306
      
  3. Path Permissions Ensure var/backups/ is writable:

    mkdir -p var/backups
    chmod -R 775 var/backups
    

Extension Points

  1. Custom Backup Strategies Extend Dizda\CloudBackupBundle\Backup\BackupManager to add:

    • Encryption (e.g., GPG before upload).
    • Pre-processing (e.g., SQL optimization).
    • Post-processing (e.g., notify Slack on failure).
  2. **

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.
emuniq/filament-browser-notifications
syriable/filament-translator
hungnm28/livewire-form
wenprise/eloquent
crudly/encrypted
fadion/bouncy
cuci/prototurk-sdk
gos/pubsub-router-bundle
cuci/prototurk-sdk-symfony
clementtalleu/easyadmin-markdown-bundle
codeflextech/permission-manager
karnoweb/livewire-datepicker
sayedenam/sayed-dashboard
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui