Extending the package
Backup Manager is built around composition over inheritance. Every capability lives behind a small interface with a focused implementation, wired together with dependency injection. This makes it straightforward to replace or extend any part — and to build a UI layer on top, which is an explicit design goal.
The backup pipeline
A backup is a pipeline of stages threaded through a shared, mutable
BackupContext:
1PrepareWorkspace → DumpDatabases → CollectSourceFiles → BuildArchive2 → CompressArchive → EncryptArchive → BuildManifest → StoreBackup → CleanupWorkspace
Each stage implements the BackupStage contract:
1namespace Nyoncode\BackupManager\Contracts\Backup;2 3interface BackupStage4{5 public function handle(BackupContext $context, Closure $next): BackupContext;6}
The ordered list of stages is injected into BackupManager, so you can add,
remove or reorder stages by re-binding it in a service provider — no core changes
required. For example, to add a stage that uploads to an external audit service
after storing, insert your stage before CleanupWorkspace.
Key contracts
| Contract | Responsibility | Default |
|---|---|---|
DatabaseDumper / DatabaseRestorer |
dump/restore one database | MySQL, PostgreSQL, SQLite |
Compressor |
compress/decompress the archive | gzip, bzip2, zstd, none |
Encryptor |
encrypt/decrypt the archive | OpenSSL AES-256, none |
Signer |
sign/verify the manifest | HMAC |
Archiver |
assemble/read the archive | streaming TAR (GNU extensions) |
BackupRepository |
list/read/delete stored backups | any Laravel disk |
RetentionStrategy |
decide which backups to keep | GFS, simple |
BackupStage |
one pipeline step | the stages above |
Swap any of them by binding your own implementation:
1use Nyoncode\BackupManager\Contracts\Compression\Compressor;2 3$this->app->bind(Compressor::class, MyCustomCompressor::class);
Adding a database engine
- Implement
DatabaseDumperandDatabaseRestorerfor your engine. - Add a case to
DatabaseManager(or bind a decorated manager) mapping yourDatabaseDriverto the new classes.
Adding a compression algorithm
Implement Compressor and add a case to CompressorManager::for().
Listening to events
1use Nyoncode\BackupManager\Events\BackupCompleted;2 3Event::listen(BackupCompleted::class, function (BackupCompleted $event) {4 // $event->result->manifest, ->archiveFileName, ->destinations5});
Building a UI on top
The package is CLI-first but UI-ready:
- Resolve
BackupManager,RestoreManager,RetentionManager,MonitorManager,VerifyManagerandBackupRepositoryfrom the container. - They return typed value objects (
BackupResult,RestoreResult,HealthReport,StoredBackup,Manifest) that map cleanly to a UI. - No console assumptions leak into these services, so a private UI package can drive the exact same code paths as the CLI.