csabourin / craft-s3-spaces-migration
Production-grade Craft CMS 4/5 module for migrating assets from AWS S3 to DigitalOcean Spaces with checkpoint/resume, rollback capabilities, and zero-downtime support.
Installs: 78
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
Type:craft-plugin
pkg:composer/csabourin/craft-s3-spaces-migration
Requires
- php: ^8.0 || ^8.1 || ^8.2 || ^8.3
- craftcms/cms: ^4.0 || ^5.0
Requires (Dev)
- craftcms/rector: dev-main
- phpstan/phpstan: ^1.10
- dev-main
- v1.5.11
- v1.5.10
- v1.5.9
- v1.5.8
- v1.5.7
- v1.5.6
- v1.5.5
- v1.5.4
- v1.5.3
- v1.5.2
- v1.5.1
- v1.5.0
- v1.4.21
- v1.4.20
- v1.4.19
- v1.4.18
- v1.4.17
- v1.4.16
- v1.4.15
- v1.4.14
- v1.4.13
- v1.4.12
- v1.4.11
- v1.4.10
- v1.4.9
- v1.4.8
- v1.4.7
- v1.4.6
- v1.4.5
- v1.4.4
- v1.4.3
- v1.4.2
- v1.4.1
- v1.4.0
- v1.3.11
- v1.3.10
- v1.3.9
- v1.3.8
- v1.3.7
- v1.3.6
- v1.3.5
- v1.3.4
- v1.3.3
- v1.3.2
- v1.3.1
- v1.3.0
- v1.2.29
- v1.2.28
- v1.2.27
- v1.2.26
- v1.2.25
- v1.2.24
- v1.2.23
- v1.2.22
- v1.2.21
- v1.2.20
- v1.2.19
- v1.2.18
- v1.2.17
- v1.2.16
- v1.2.15
- v1.2.14
- v1.2.13
- v1.2.12
- v1.2.11
- v1.2.10
- v1.2.9
- v1.2.8
- v1.2.7
- v1.2.6
- v1.2.5
- v1.2.4
- v1.2.3
- v1.2.2
- v1.2.1
- v1.2.0
- v1.1.12
- v1.1.11
- v1.1.10
- v1.1.9
- v1.1.8
- v1.1.7
- v1.1.6
- v1.1.5
- v1.1.4
- v1.1.3
- v1.1.2
- v1.1.1
- v1.1.0
- v1.0.17
- v1.0.16
- v1.0.15
- v1.0.14
- v1.0.13
- v1.0.12
- v1.0.11
- v1.0.10
- v1.0.9
- v1.0.8
- v1.0.7
- v1.0.6
- v1.0.5
- v1.0.4
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0.0
- dev-claude/fix-json-import-settings-018RReAos2nYro1TYqZFDBf5
- dev-claude/transform-cleanup-controller-01AbK8CGeyLCHExdqX1ATy4N
- dev-claude/fix-beforeaction-signature-01UwrXYuTCvBQyYMawtfWFyg
- dev-codex/fix-settings-page-tabs-functionality-ajbgt7
- dev-codex/fix-settings-page-tabs-functionality
- dev-codex/create-cli-module-for-cleanup-and-migration
- dev-claude/configure-s3-volumes-01P7T2kKMKHkChBXA8MdgvXR
- dev-claude/fix-json-import-tabs-01B8986gwo39zrBFyZbGS4ix
- dev-claude/web-prerequisites-update-01VCzTLehuLmb5xD1RfkgDt7
- dev-claude/fix-volume-consolidation-asset-filtering-01SR3zFo6EHu4XofF6KZb9be
- dev-claude/fix-config-status-settings-01E5aWHDqC388p1WcvCuEuxG
- dev-claude/fix-migration-config-error-01RKazSZHb35335fQHLkPyzq
- dev-claude/review-migration-controller-01Fh2eDHiVKyxSeYHSAMdz84
- dev-claude/migrate-plugin-settings-db-01Qu1FNcmSy2hvCjYoJozW7X
- dev-claude/save-memory-context-db-01NpvDQuQURdyJ5EjUWrPTy9
- dev-claude/refactor-console-command-execution-01DZ7zUSugpmYu3K1JiAsiJQ
- dev-claude/plugin-settings-interface-014LjXCPZS17v8hZQTj27dGP
- dev-claude/fix-flag-module-failures-011ZhPafhEDnZwbnhsoK9cSC
- dev-claude/use-plugin-settings-store-01VCXAig9DRh7TKSJTgMUpmx
- dev-claude/fix-undefined-dryrun-variable-011CV6Ceb28kmAoDHiFZFN9y
- dev-claude/fix-migrate-files-do-page-not-found-011CV54gf9ZcmvTNTHebAwcZ
- dev-claude/file-move-module-011CV53d69juPmXgUcX2egst
- dev-claude/enable-dryrun-cli-modules-011CV4bNT9LqB7KvXmsNeaQG
- dev-claude/fix-notepad-icon-display-011CV4ZKGECvsdYxpBB6kX1m
- dev-claude/improve-ui-ux-011CV4Wph4QQDtthJdCkv5yD
- dev-claude/s3-migration-diagnostics-011CV4TEt8cUtwuDPCri5zGY
- dev-claude/image-migration-queue-debug-011CV4Gc7suSzXrpmwx4Z92o
- dev-claude/fix-migration-state-service-011CV4FxfbZwsEHrLSmfurQe
- dev-claude/handle-long-running-modules-011CV4DaqV3RM9Xni42SgeFD
- dev-claude/fix-migration-refresh-011CV4CcifxTt3v6Lm8YY2fD
- dev-claude/fix-file-copy-error-011CV48hBJz94g6uP3MyHUmy
- dev-claude/review-image-migration-controller-011CV3uSxQSGTASTELmhFRdS
- dev-claude/fix-image-migration-errors-011CV3swFHz9Jn6sw5Dod2oA
- dev-claude/fix-file-migration-011CV2w7qX9LowrYXybgmE5k
- dev-claude/review-documentation-011CV2vGnQkq6qWvKSybmcDn
- dev-claude/fix-image-migration-broken-pipe-011CV2myUGwzdvDbq1yLaYRF
- dev-claude/asset-file-indexing-011CV2h9ZSSGKWB3mjHtTpA5
- dev-claude/fix-accessibility-css-issues-011CV2gFezcowKCVWHaEXJsr
- dev-claude/setup-digitalocean-spaces-011CV2cuCrq6McNhWSgQMavz
- dev-claude/test-file-operations-011CV2TZWnVAYBigtAm7pnx6
- dev-claude/fix-lazy-asset-lookup-error-011CV2KEi3SUwYxWedxdNzAi
- dev-codex/introduce-migrationprogressservice-and-update-controller
- dev-codex/add-migration-button-attributes-and-listeners
- dev-claude/fix-migrate-files-do-011CV1HNNpnAFt3HKcWctTTa
- dev-claude/fix-skip-confirmation-option-011CV1G35z7GJreTo3HaC1Gz
- dev-codex/fix-live-console-output-in-web-module
- dev-codex/fix-live-console-output-in-web-module-qn1v8f
- dev-codex/fix-live-console-output-in-web-module-r3dqkr
- dev-claude/reorder-env-config-step-011CUznA7ZZ4XoNX3UMyJ2SF
- dev-claude/fix-checkpoint-manager-class-011CUzkFagcKK6mRqRenf9Fq
- dev-claude/review-migration-module-011CUzfX2yVja3KrhAfiNEQz
- dev-codex/fix-unknownmethodexception-in-imagemigrationcontroller
- dev-claude/interrupt-long-modules-011CUzNJy9k7Yn15fqSxZdUd
- dev-claude/fix-s3-spaces-migration-011CUzLm1ztGsJrmb7VwMUP2
- dev-claude/fix-web-interface-011CUzHgDELLCXzv1oYEsj37
- dev-claude/fix-s3-spaces-migration-route-011CUzGRVX5HMMB6uZ9dX9Uh
- dev-claude/automate-cli-commands-011CUzEqT3gNpchsL4N9M1sR
- dev-codex/remove-ncc-website-2-from-code-and-docs
This package is auto-updated.
Last update: 2025-11-15 00:21:09 UTC
README
Production-grade Craft CMS 4/5 module for migrating assets from AWS S3 to DigitalOcean Spaces with checkpoint/resume, rollback capabilities, and zero-downtime support.
β¨ Highlights
- Production-Ready: Battle-tested migration toolkit with enterprise-grade reliability
- Checkpoint/Resume System: Survive interruptions and resume from exactly where you left off
- Complete Rollback: Full rollback capabilities with comprehensive change logs
- Zero Dependencies: Works with just Craft CMS - no additional packages required
- Auto-Bootstrap: PSR-4 autoloaded - no manual configuration in
config/app.php - Memory Efficient: Handles 100,000+ assets with intelligent batch processing
- Comprehensive Dashboard: Web-based Control Panel for orchestration and monitoring
π― Key Features
Migration Capabilities
- 14 Specialized Controllers for different migration phases
- Batch Processing with configurable batch sizes for memory efficiency
- Dry Run Mode to test migrations without making changes
- Progress Tracking with real-time ETA and throughput metrics
- Error Recovery with automatic retry logic and health checks
- Idempotent Operations - safe to run multiple times
Control Panel Dashboard
- Web-based interface for migration orchestration
- Real-time status monitoring
- Command execution from the browser
- Checkpoint inspection tools
- Live log streaming
- Connection testing
Developer Experience
- Centralized configuration via
MigrationConfighelper - 40+ type-safe configuration methods
- Comprehensive inline documentation
- Extensive architecture documentation
- Custom Twig filters included
π Requirements
- PHP: 8.0 or higher
- Craft CMS: 4.0+ or 5.0+
- AWS S3: Source bucket with read access
- DigitalOcean Spaces: Target bucket with write access
π Installation
1. Install via Composer
composer require csabourin/craft-s3-spaces-migration
The plugin will auto-install and automatically create config/migration-config.php if it doesn't exist.
2. Configure Environment Variables
Add these to your .env file:
# Migration Environment MIGRATION_ENV=dev # DigitalOcean Spaces Credentials DO_S3_ACCESS_KEY=your_spaces_access_key DO_S3_SECRET_KEY=your_spaces_secret_key DO_S3_BUCKET=your-bucket-name DO_S3_BASE_URL=https://your-bucket.tor1.digitaloceanspaces.com DO_S3_BASE_ENDPOINT=https://tor1.digitaloceanspaces.com
See .env.example for all available options.
3. Update Migration Config
Edit config/migration-config.php:
$awsSource = [ 'bucket' => 'your-aws-bucket', // β Update this 'region' => 'us-east-1', // β Update this ];
4. Verify Installation
./craft s3-spaces-migration/migration-check/check
π Usage
Console Commands
Pre-Flight Check
./craft s3-spaces-migration/migration-check/check
Migrate Assets (Dry Run)
./craft s3-spaces-migration/image-migration/migrate --dryRun=1
Migrate Assets (Production)
./craft s3-spaces-migration/image-migration/migrate
Replace URLs in Database
./craft s3-spaces-migration/url-replacement/replace-s3-urls
Switch Filesystems
./craft s3-spaces-migration/filesystem-switch/to-do
Post-Migration Diagnostics
./craft s3-spaces-migration/migration-diag/diagnose
Web Dashboard
Access the migration dashboard in your Control Panel:
Control Panel β Migration β Dashboard
The dashboard provides:
- Step-by-step migration guidance
- Real-time progress monitoring
- Command execution interface
- Configuration validation
- Checkpoint management
πΊοΈ Migration Workflow
The complete migration process follows these phases:
- Pre-Flight Validation - Verify configuration and connectivity
- Database URL Replacement - Update S3 URLs in content tables
- Template URL Replacement - Update hardcoded URLs in Twig templates
- File Migration - Copy physical assets from AWS to DigitalOcean
- Filesystem Switch - Switch volumes to use DigitalOcean Spaces
- Configuration Updates - Update plugin configs and field settings
- Transform Management - Discover and pre-generate image transforms
- Post-Migration Verification - Validate successful migration
Each phase is modular and can be executed independently or in sequence.
OptimisedImages transform cleanup (new CLI module)
Before running the file migration or cleanup commands, purge stale transform files that live inside underscore-prefixed folders (for example _1200x800/hero.jpg) within the Optimised Images volume (ID 4). This prevents copying millions of auto-generated transforms to the new filesystem and keeps the migration delta small.
# Preview everything that would be removed ./craft s3-spaces-migration/transform-cleanup/clean --dryRun=1 # Execute the cleanup ./craft s3-spaces-migration/transform-cleanup/clean --dryRun=0
Each run saves a JSON report under storage/runtime/transform-cleanup/ so you can audit which files were targeted.
π Module Structure
modules/
βββ module.php # Module entry point
βββ controllers/ # Web controllers
β βββ DefaultController.php
β βββ MigrationController.php # Dashboard controller
βββ console/controllers/ # 14 console controllers
β βββ MigrationCheckController.php
β βββ ImageMigrationController.php
β βββ FilesystemSwitchController.php
β βββ ... (11 more)
βββ helpers/
β βββ MigrationConfig.php # Centralized configuration
βββ templates/s3-spaces-migration/
βββ dashboard.twig # Control Panel interface
π Documentation
- ARCHITECTURE.md - System design and technical details
- DASHBOARD.md - Control Panel dashboard guide
- PRODUCTION_RUNBOOK.md - Production deployment and troubleshooting
- CHANGELOG.md - Version history
- CONTRIBUTING.md - Contribution guidelines
- SECURITY.md - Security policy and best practices
π§ Configuration
The module uses a centralized configuration system with three layers:
- Environment Variables (
.env) - Credentials and secrets - Configuration File (
config/migration-config.php) - Migration settings - Helper Class (
MigrationConfig) - Type-safe access to config values
Key Configuration Options
return [ 'aws' => [ 'bucket' => 'your-source-bucket', 'region' => 'us-east-1', ], 'do' => [ 'bucket' => App::env('DO_S3_BUCKET'), 'region' => 'tor1', 'accessKey' => App::env('DO_S3_ACCESS_KEY'), 'secretKey' => App::env('DO_S3_SECRET_KEY'), ], 'migration' => [ 'batchSize' => 100, 'checkpointFrequency' => 50, 'maxRetries' => 3, ], ];
π‘οΈ Safety Features
- Dry Run Mode: Test all operations before execution
- Checkpoint System: Automatic progress saving every N items
- Rollback Capability: Complete undo with change logs
- Health Checks: Continuous validation during migration
- Error Recovery: Automatic retry with exponential backoff
- Audit Logging: Comprehensive logs of all operations
π€ Contributing
Contributions are welcome! Please see CONTRIBUTING.md for details.
Development Setup
- Fork and clone the repository
- Install dependencies:
composer install - Set up a test Craft CMS installation
- Configure test AWS S3 and DigitalOcean Spaces accounts
- Run pre-flight checks:
./craft s3-spaces-migration/migration-check/check
π License
This project is licensed under the MIT License - see the LICENSE file for details.
π Acknowledgments
- Built for Craft CMS by Pixel & Tonic
- Inspired by real-world enterprise migration needs
- Tested on production sites with millions of assets
π¬ Support
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Documentation: Architecture Guide
π Links
- Repository: https://github.com/csabourin/do-migration
- Packagist: https://packagist.org/packages/csabourin/craft-s3-spaces-migration
- Craft CMS: https://craftcms.com/
- DigitalOcean Spaces: https://www.digitalocean.com/products/spaces
Made with β€οΈ for the Craft CMS community