New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

backup-manager/laravel

Database backup manager integrated with Laravel: back up and restore MySQL and PostgreSQL to S3, Google Cloud Storage, Dropbox, FTP, SFTP, WebDAV and more.
816,654 656
Install
composer require backup-manager/laravel
Latest Version:3.1.0
PHP:^8.2
Laravel:12 · 13
Older releases:4 – 11
License:MIT
Last Updated:Nov 22, 2026
Links: GitHub  ·  Packagist
Maintainer: ShawnMcCool

Laravel Driver for the Database Backup Manager

Tests Latest Version PHP Version Laravel Downloads License

Back up and restore your Laravel application's MySQL and PostgreSQL databases to S3, Google Cloud Storage, Dropbox, FTP, SFTP, WebDAV or local disk, from Artisan or from your own code.

This package integrates the framework-agnostic Backup Manager into Laravel. For the core library or the Symfony integration, see the core repository.

Requirements

  • PHP 8.2+
  • Laravel 12 or 13. For Laravel 7–11 use version 2.x; every release of those lines has an unpatched security advisory.
  • MySQL or MariaDB: the mysqldump and mysql binaries
  • PostgreSQL: the pg_dump and psql binaries
  • Gzip compression: the gzip and gunzip binaries

Installation

composer require backup-manager/laravel

The service provider is registered by package discovery. Publish the storage configuration:

php artisan vendor:publish --provider="BackupManager\Laravel\BackupManagerServiceProvider"

Then install the Flysystem 3 adapter package for each storage type you use:

Type Package (Flysystem 3)
Local included
AwsS3 league/flysystem-aws-s3-v3
AsyncAwsS3 league/flysystem-async-aws-s3
Gcs league/flysystem-google-cloud-storage
Dropbox spatie/flysystem-dropbox
Ftp league/flysystem-ftp
Sftp league/flysystem-sftp-v3
Webdav league/flysystem-webdav

If a package is missing, the backup fails with an error naming the package to install. To add your own filesystem type, extend the binding in a service provider:

$this->app->extend(FilesystemProvider::class, fn ($provider) => tap($provider)->add(new MyFilesystem()));

Configuration

Storage connections live in config/backup-manager.php. Each entry has a type and that type's settings. S3-compatible services (DigitalOcean Spaces, MinIO, ...) use the AwsS3 type with an endpoint (and use_path_style_endpoint where the service needs it).

Databases come from Laravel's own config/database.php connections; mysql, mariadb and pgsql connections can be backed up. MySQL and MariaDB connections accept these extra keys, which Laravel ignores and the backup uses:

'mysql' => [
    'driver' => 'mysql',
    // ... Laravel's usual keys; url (DB_URL) and unix_socket are used when set ...
    'singleTransaction' => true,         // --single-transaction (InnoDB)
    'ignoreTables' => ['sessions'],      // --ignore-table for each
    'onlyTables' => ['users', 'orders'], // dump only these tables
    'ssl' => false,                      // --ssl
    'columnStatistics' => false,         // --column-statistics=0 (MySQL 8 mysqldump against older servers)
    'extraParams' => '--max-allowed-packet=64M', // appended to mysqldump
],

extraParams defaults to the BACKUP_MANAGER_EXTRA_PARAMS environment variable for every connection that does not set it.

Configuration is read when a backup runs, so connections changed at runtime with config([...]) are used, for example a tenant database selected before calling db:backup.

Artisan commands

db:backup, db:restore and db:list prompt for any option you leave out. In a non-interactive run (the scheduler, --no-interaction) a missing option is an error instead.

php artisan db:backup --database=mysql --destination=s3 --destinationPath=project/backup --timestamp="Y-m-d_H-i-s" --compression=gzip
php artisan db:list --source=s3 --path=project
php artisan db:restore --source=s3 --sourcePath=project/backup2026-11-22_04-00-00.gz --database=mysql --compression=gzip

--timestamp is a date format appended to the destination path; the compressor adds its extension (.gz).

Using the Manager in code

BackupManager\Manager is resolved by the container:

use BackupManager\Filesystems\Destination;
use BackupManager\Manager;

public function backup(Manager $manager)
{
    $manager->makeBackup()->run('mysql', [new Destination('s3', 'project/backup.sql')], 'gzip');
}

This package backs up databases only. To delete old backups, use your storage's lifecycle rules (for example S3 lifecycle expiration) or Laravel's Storage facade.

Scheduling backups

// routes/console.php (Laravel 11+) or the schedule() method of app/Console/Kernel.php
Schedule::command('db:backup --database=mysql --destination=s3 --destinationPath=' . app()->environment() . '/backup --timestamp="Y_m_d_H_i_s" --compression=gzip')
    ->twiceDaily(13, 21);

Supported versions

Version Laravel PHP Core library Support
3.x 12, 13 8.2+ 4.x active
2.x 7–13 7.4+ 3.x security fixes until 2027-12-31

Upgrading

See UPGRADE.md.

Contributing

Run the tests with vendor/bin/phpunit; CI also runs PHPStan, Psalm and PHP-CS-Fixer (PSR-12). The MySQL backup-and-restore test runs when BACKUP_MANAGER_TEST_MYSQL_PASSWORD is set (root user, database backup_manager_test on 127.0.0.1 and the default socket); CI runs it on every Laravel version. Proposals for new features are welcome as issues.

Maintained by Shawn McCool and contributors.

License

MIT. See CHANGELOG.md for release notes.

Related Packages

paulocastellano/laravel-database-backup

Back up your Laravel database (PostgreSQL, MySQL, MariaDB) to a private S3-compa...

1,964 3
crysalead/sql-dialect

SQL query builder.

13,487 6
devtheorem/peachy-sql

A high-performance query builder and runner for PHP

2,888 23
usmanhalalit/pixie

A lightweight, expressive, framework agnostic query builder for PHP.

2,322,021 674

Version History

Version Released PHP Laravel License
3.1.0 ^8.2 ^12.71.0 || ^13.40.0 MIT
3.0.0 ^8.2 ^12.71.0 || ^13.40.0 MIT
2.2.0 ^7.4 || ^8.0 ^7.0 || ^8.0 || ^9.0 || ^10.0 || ^11.0 || ^12.0 || ^13.0 MIT
2.1.0 ^7.4 || ^8.0 ^7.0 || ^8.0 || ^9.0 || ^10.0 || ^11.0 || ^12.0 || ^13.0 MIT
2.0 ^7.3||^7.4 ^5.5||^6||^7 MIT