Looking to hire Laravel developers? Try LaraJobs

laravel-db-backup maintained by sulaimanbarki

Description
A lightweight database backup download route package for Laravel.
Last update
2026/05/18 12:01 (dev-main)
License
Links
Downloads
2

Comments
comments powered by Disqus

Laravel Database Backup

Latest Version on Packagist Total Downloads Software License

A lightweight, zero-configuration Laravel package to quickly download your database as an SQL backup file directly from your browser.

Perfect for small-to-medium projects that need a fast, simple, and completely open database backup mechanism without any authorization constraints.

[!CAUTION] Security Warning: This package registers a public route /backupdb with no authentication or authorization checks. Anyone who visits this URL will be able to download your entire database. Use with caution or only in protected environments.


🚀 How It Works

  1. Automatic Route Registration: The package automatically registers a public route at /backupdb (named db-backup.download).
  2. No Authentication Constraints: The route has no restrictions, making it accessible to both guests and authenticated users.
  3. Smart Backup Generation:
    • Queries all database tables safely using SHOW TABLES and sanitizes identifiers.
    • Fetches table schemas using SHOW CREATE TABLE.
    • Generates fully standard, formatted INSERT INTO statements for all records (with proper handling for NULL values and SQL escaping).
  4. Zero Disk Footprint: Streams the backup file (.sql) to the client immediately and deletes the temporary file from the server right after the transfer is complete.

📦 Installation

Install the package via composer:

composer require sulaimanbarki/laravel-db-backup

⚙️ Auto-Discovery

This package uses Laravel's package auto-discovery feature. The service provider sulaimanbarki\DbBackup\DbBackupServiceProvider is automatically registered. You don't need to manually add it to your config/app.php.


🛠️ Usage

Once installed, you can access the backup route /backupdb or dynamically link to it in your templates.

Direct Access

Navigate directly to:

https://your-domain.com/backupdb

Linking in Blade Views

Generate a link to the download page using the route helper:

<a href="{{ route('db-backup.download') }}" class="btn btn-primary">
  <i class="fa fa-download"></i> Download Database Backup
</a>

🛠️ Tech Specs & Support

  • PHP Version: ^8.0
  • Laravel Framework: ^9.0, ^10.0, or ^11.0
  • Database Engine: MySQL / MariaDB (requires support for SHOW TABLES and SHOW CREATE TABLE).

📄 License

The MIT License (MIT). Please see License File for more information.