sulaimanbarki/laravel-db-backup

A lightweight database backup download route package for Laravel.

Maintainers

Package info

github.com/sulaimanbarki/laravel-db-backup

pkg:composer/sulaimanbarki/laravel-db-backup

Statistics

Installs: 6

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.2 2026-05-18 10:01 UTC

This package is auto-updated.

Last update: 2026-05-18 10:02:09 UTC


README

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.