Top Related Projects
Database backup manager for dumping to and restoring databases from S3, Dropbox, FTP, SFTP, and Rackspace Cloud
Backend controllers and scaffolding for Laravel authentication.
Laravel Sanctum provides a featherweight authentication system for SPAs and simple APIs.
Debugbar for Laravel (Integrates PHP Debug Bar)
Associate users with roles and permissions
Associate files with Eloquent models
Quick Overview
Spatie's Laravel Backup is a powerful package for Laravel applications that provides an easy way to backup your database and files. It offers flexible configuration options, supports multiple storage systems, and includes features like database dumping, file compression, and cleanup of old backups.
Pros
- Easy to set up and use with Laravel applications
- Supports multiple storage systems (local, S3, Dropbox, etc.)
- Offers both database and file backups
- Includes a cleanup feature to manage backup storage
Cons
- Limited to Laravel applications
- May require additional configuration for complex backup scenarios
- Large file backups can be time-consuming and resource-intensive
- Requires proper server configuration for optimal performance
Code Examples
- Creating a backup:
use Spatie\Backup\Tasks\Backup\BackupJob;
$backupJob = new BackupJob(config('backup'));
$backupJob->run();
- Listing all backups:
use Spatie\Backup\BackupDestination\BackupDestinationFactory;
$backupDestination = BackupDestinationFactory::createFromArray(config('backup.backup'));
$backups = $backupDestination->backups();
foreach ($backups as $backup) {
echo $backup->path();
}
- Cleaning up old backups:
use Spatie\Backup\Tasks\Cleanup\CleanupJob;
$cleanupJob = new CleanupJob(config('backup'));
$cleanupJob->run();
Getting Started
- Install the package via Composer:
composer require spatie/laravel-backup
- Publish the configuration file:
php artisan vendor:publish --provider="Spatie\Backup\BackupServiceProvider"
- Configure your backup settings in
config/backup.php
:
return [
'backup' => [
'name' => env('APP_NAME', 'laravel-backup'),
'source' => [
'files' => [
'include' => [
base_path(),
],
'exclude' => [
base_path('vendor'),
base_path('node_modules'),
],
],
'databases' => [
'mysql',
],
],
'destination' => [
'filename_prefix' => 'backup-',
'disks' => [
'local',
],
],
],
];
- Run your first backup:
php artisan backup:run
Competitor Comparisons
Database backup manager for dumping to and restoring databases from S3, Dropbox, FTP, SFTP, and Rackspace Cloud
Pros of backup-manager
- More flexible, supporting multiple storage systems and databases
- Can be used in non-Laravel PHP projects
- Offers a command-line interface for easier integration with other tools
Cons of backup-manager
- Less Laravel-specific features and integration
- Requires more manual configuration
- Not actively maintained (last commit over 3 years ago)
Code Comparison
backup-manager:
use BackupManager\Filesystems\Destination;
use BackupManager\Config\Config;
use BackupManager\Backup\MySqlBackupProcess;
$backup = new MySqlBackupProcess($config);
$backup->process(new Destination('s3', 'bucket/path/backup.sql'));
laravel-backup:
use Spatie\Backup\Tasks\Backup\BackupJob;
$backupJob = new BackupJob(config('backup'));
$backupJob->run();
The backup-manager example shows more explicit configuration and process control, while laravel-backup leverages Laravel's configuration system for a more streamlined approach.
Backend controllers and scaffolding for Laravel authentication.
Pros of Fortify
- Focuses on authentication and security features, providing a robust foundation for user management
- Seamlessly integrates with Laravel's ecosystem, offering features like two-factor authentication and password reset
- Regularly updated and maintained by the Laravel team, ensuring compatibility with the latest Laravel versions
Cons of Fortify
- Limited in scope compared to Laravel Backup, as it doesn't provide backup functionality
- Requires additional configuration and setup for full implementation of authentication features
- May introduce complexity for simple projects that don't require advanced authentication features
Code Comparison
Laravel Backup example:
use Spatie\Backup\Tasks\Backup\BackupJob;
$backupJob = new BackupJob(config('backup'));
$backupJob->run();
Fortify example:
use Laravel\Fortify\Features;
Fortify::registerView(function () {
return view('auth.register');
});
While Laravel Backup focuses on creating and managing backups, Fortify provides authentication scaffolding and security features. The code examples demonstrate their different purposes: Laravel Backup initiates a backup job, while Fortify configures authentication views and features.
Laravel Sanctum provides a featherweight authentication system for SPAs and simple APIs.
Pros of Sanctum
- Lightweight and easy to implement API token authentication
- Seamless integration with Laravel's built-in authentication system
- Supports SPA authentication out of the box
Cons of Sanctum
- Limited to API token and SPA authentication, not as versatile for other backup scenarios
- Doesn't provide backup or restoration functionality
Code Comparison
Sanctum (API token creation):
$token = $user->createToken('token-name');
Laravel-backup (Backup configuration):
'backup' => [
'name' => 'project_name',
'source' => [
'files' => [
base_path(),
],
],
'destination' => [
'disks' => ['s3'],
],
],
Summary
Sanctum is a lightweight package focused on API token authentication and SPA authentication for Laravel applications. It's easy to implement and integrates well with Laravel's existing authentication system. However, it's limited in scope compared to Laravel-backup.
Laravel-backup, on the other hand, is a comprehensive backup solution for Laravel applications. It provides functionality for backing up files and databases, with options for different storage destinations. While it doesn't offer authentication features, it excels in its primary purpose of creating and managing backups.
The choice between these packages depends on the specific needs of your project. If you require API authentication, Sanctum is an excellent choice. For backup and restoration capabilities, Laravel-backup is the more suitable option.
Debugbar for Laravel (Integrates PHP Debug Bar)
Pros of Laravel Debugbar
- Provides real-time debugging information in the browser
- Offers detailed insights into queries, views, and performance metrics
- Easy to install and integrate into existing Laravel projects
Cons of Laravel Debugbar
- Can impact performance when enabled in production environments
- May expose sensitive information if not properly configured
- Focuses on debugging rather than data protection and recovery
Code Comparison
Laravel Debugbar:
use Barryvdh\Debugbar\Facade as Debugbar;
Debugbar::info('Info message');
Debugbar::error('Error message');
Debugbar::warning('Warning message');
Laravel Backup:
use Spatie\Backup\Tasks\Backup\BackupJob;
$backupJob = new BackupJob(config('backup'));
$backupJob->run();
While Laravel Debugbar is primarily used for debugging and performance analysis, Laravel Backup focuses on creating and managing backups of your Laravel application. Laravel Debugbar provides immediate feedback during development, whereas Laravel Backup ensures data safety and recovery options. The choice between these packages depends on your specific needs: debugging and optimization versus data protection and disaster recovery.
Associate users with roles and permissions
Pros of laravel-permission
- Focused on role-based access control, providing a more specialized solution for managing user permissions
- Offers a simpler API for assigning and checking permissions, making it easier to implement in Laravel applications
- Supports caching of permissions, improving performance in large-scale applications
Cons of laravel-permission
- Limited to permission management, lacking the comprehensive backup functionality of laravel-backup
- May require additional setup and configuration for complex permission structures
Code Comparison
laravel-permission:
$user->givePermissionTo('edit articles');
$user->hasPermissionTo('edit articles');
laravel-backup:
Artisan::call('backup:run');
Artisan::call('backup:clean');
Key Differences
laravel-permission is specifically designed for managing user roles and permissions in Laravel applications, while laravel-backup focuses on creating and managing backups of Laravel projects. The choice between these packages depends on the specific needs of your project:
- Use laravel-permission for implementing role-based access control
- Use laravel-backup for creating automated backups of your Laravel application
Both packages are well-maintained and widely used in the Laravel community, offering robust solutions for their respective purposes.
Associate files with Eloquent models
Pros of laravel-medialibrary
- Specialized for handling media files and attachments
- Supports image manipulations and conversions out of the box
- Offers flexible file organization with collections and custom properties
Cons of laravel-medialibrary
- More complex setup and configuration compared to laravel-backup
- Focused solely on media management, not general backup functionality
- May require additional storage considerations for large media libraries
Code Comparison
laravel-medialibrary:
$model->addMedia($pathToFile)->toMediaCollection('images');
$model->getMedia('images')->first()->getUrl('thumb');
laravel-backup:
Artisan::call('backup:run');
Artisan::call('backup:clean');
Summary
laravel-medialibrary is a powerful tool for managing media files in Laravel applications, offering advanced features like image manipulations and collections. However, it's more specialized and complex compared to laravel-backup, which provides a straightforward solution for backing up your entire Laravel application, including databases and files. While laravel-medialibrary excels in media management, laravel-backup offers a more comprehensive approach to data protection and disaster recovery for your entire Laravel project.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
A modern backup solution for Laravel apps
This Laravel package creates a backup of your application. The backup is a zip file that contains all files in the directories you specify along with a dump of your database. The backup can be stored on any of the filesystems you have configured in Laravel.
Feeling paranoid about backups? No problem! You can backup your application to multiple filesystems at once.
Once installed taking a backup of your files and databases is very easy. Just issue this artisan command:
php artisan backup:run
But we didn't stop there. The package also provides a backup monitor to check the health of your backups. You can be notified via several channels when a problem with one of your backups is found. To avoid using excessive disk space, the package can also clean up old backups.
Support us
We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.
We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.
Installation and usage
This package requires PHP 8.2 and Laravel 10.0 or higher. You'll find installation instructions and full documentation on https://spatie.be/docs/laravel-backup.
Using an older version of PHP / Laravel?
If you are on a PHP version below 8.0 or a Laravel version below 8.0 just use an older version of this package.
Read the extensive documentation on version 3, on version 4, on version 5 and on version 6. We will not be introducing any new features to v6 and below. We will however continue to update for bugs as neccesary.
Testing
Run the tests with:
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security-related issues, please email security@spatie.be instead of using the issue tracker.
Postcardware
You're free to use this package, but if it makes it to your production environment we highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using.
Our address is: Spatie, Kruikstraat 22, 2018 Antwerp, Belgium.
We publish all received postcards on our company website.
Credits
And a special thanks to Caneco for the logo â¨
License
The MIT License (MIT). Please see License File for more information.
Top Related Projects
Database backup manager for dumping to and restoring databases from S3, Dropbox, FTP, SFTP, and Rackspace Cloud
Backend controllers and scaffolding for Laravel authentication.
Laravel Sanctum provides a featherweight authentication system for SPAs and simple APIs.
Debugbar for Laravel (Integrates PHP Debug Bar)
Associate users with roles and permissions
Associate files with Eloquent models
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot