Download the PHP package amdadulhaq/database-backup-laravel without Composer
On this page you can find all versions of the php package amdadulhaq/database-backup-laravel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download amdadulhaq/database-backup-laravel
More information about amdadulhaq/database-backup-laravel
Files in amdadulhaq/database-backup-laravel
Package database-backup-laravel
Short Description Simple database backups for Laravel (PostgreSQL, MySQL, MariaDB, SQLite) streamed to any filesystem disk, including S3-compatible APIs like Cloudflare R2.
License MIT
Homepage https://github.com/amdad121/database-backup-laravel
Informations about the package database-backup-laravel
Database Backup for Laravel
Simple database backups for Laravel. Dumps one PostgreSQL or MySQL / MariaDB connection (SQLite also supported) and stores it on any Laravel filesystem disk — the local disk by default, or an S3-compatible API such as Cloudflare R2, MinIO, DigitalOcean Spaces, Backblaze B2 or AWS S3.
Requirements
- PHP 8.2, 8.3, 8.4, or 8.5
- Laravel 12 or 13
- PHP extensions
intlandzlib;pdo_sqlitewith SQLite 3.27+ for SQLite backups pg_dumpfor PostgreSQL,mysqldumpfor MySQL/MariaDB (SQLite needs neither)league/flysystem-aws-s3-v3when the destination disk is an S3 disk
Installation
You can install the package via composer:
Publish the config file:
The service provider is auto-discovered.
Destination disk
Any disk from config/filesystems.php works. Point DB_BACKUP_DISK at it.
AWS S3
Cloudflare R2
MinIO
DigitalOcean Spaces
Backblaze B2 (S3-compatible)
Local / any other disk
Usage
Schedule it in routes/console.php:
Restore
The file is pulled from the backup disk, gunzipped if needed, then piped into
psql / mysql (a SQLite file is swapped in atomically and its stale -wal /
-shm files are removed). PostgreSQL restores run in a single transaction with
ON_ERROR_STOP, and the default pg_dump options include --clean --if-exists
so a restore drops existing objects first. MySQL restores stop at the first
error; mysqldump emits DROP TABLE IF EXISTS for every table in the dump, but
tables that exist in the target and not in the backup are left in place.
MySQL / MariaDB restores are not transactional. DDL (
DROP/CREATE TABLE) commits immediately, so a restore that fails halfway leaves the database partially restored. Take a fresh backup before restoring.
The backup's type must match the connection: a .sql[.gz] file for
pgsql / mysql / mariadb, a .sqlite[.gz] file for sqlite.
Configuration (config/database-backup.php / env)
| Option | Env | Default | Purpose |
|---|---|---|---|
connection |
DB_BACKUP_CONNECTION |
DB_CONNECTION |
Connection to dump |
disk |
DB_BACKUP_DISK |
local |
Destination filesystem disk |
path |
DB_BACKUP_PATH |
slug of APP_NAME |
Root folder on the disk (so several sites can share one bucket) |
compress |
DB_BACKUP_COMPRESS |
true |
gzip the dump before upload |
retention.keep_last |
DB_BACKUP_KEEP_LAST |
7 |
Keep at most N backups for the connection (0 = unlimited) |
retention.keep_days |
DB_BACKUP_KEEP_DAYS |
30 |
Delete backups older than N days (0 = off) |
timeout |
DB_BACKUP_TIMEOUT |
900 |
Max seconds for the dump |
temp_directory |
DB_BACKUP_TEMP_DIR |
{system temp}/database-backup-{uid} |
Local scratch dir (dump/restore), resolved per user at runtime |
binaries.* |
DB_BACKUP_BIN_MYSQLDUMP / DB_BACKUP_BIN_MYSQL / DB_BACKUP_BIN_PGDUMP / DB_BACKUP_BIN_PSQL / DB_BACKUP_BIN_MARIADB_DUMP / DB_BACKUP_BIN_MARIADB |
on $PATH |
Paths to mysqldump / mysql / pg_dump / psql |
extra_options.* |
— | see config | Raw args appended per driver (mysql, mariadb, pgsql) |
Backups are stored per connection as
{path}/{connection}/{connection}-{database}-{Y-m-d_His}.sql (.sqlite for SQLite,
.gz appended when compression is on). A short random suffix keeps backups started
in the same second apart, and a .sha256 checksum is stored next to each backup
and verified before a restore. The folder uses the connection name as-is. Backups written by older releases directly into {path}/ are
still listed, restored and pruned when their name matches the connection and
database exactly.
Connections are resolved like Laravel does: url / DB_URL is expanded, and for
read/write splits the write host is used. PostgreSQL sslmode, sslcert,
sslkey and sslrootcert are passed to pg_dump / psql; MySQL SSL PDO options
(PDO::MYSQL_ATTR_SSL_CA, _CERT, _KEY, _CAPATH, _CIPHER,
_VERIFY_SERVER_CERT) become --ssl-* flags. The MySQL password is passed in a
private option file (--defaults-extra-file), not the environment. Local dump files
are created with mode 0600 in a per-user 0700 temp directory.
Events
AmdadulHaq\DatabaseBackup\Events\BackupCompleted—connection,disk,remotePath,bytesAmdadulHaq\DatabaseBackup\Events\BackupFailed—connection,exceptionAmdadulHaq\DatabaseBackup\Events\BackupPruneFailed—connection,exception(the backup itself succeeded)AmdadulHaq\DatabaseBackup\Events\BackupChecksumFailed—connection,remotePath,exception(the backup itself succeeded)AmdadulHaq\DatabaseBackup\Events\RestoreCompleted—connection,disk,remotePathAmdadulHaq\DatabaseBackup\Events\RestoreFailed—connection,exception
Drivers
Each database type is a small class implementing the Dumper contract
(src/Dumpers/) and the Restorer contract (src/Restorers/):
| Driver | Backup | Restore |
|---|---|---|
pgsql |
pg_dump |
psql |
mysql |
mysqldump |
mysql |
mariadb |
mariadb-dump (falls back to mysqldump) |
mariadb (falls back to mysql) |
sqlite |
VACUUM INTO snapshot |
atomic file swap |
Testing
The integration tests back up and restore a real MySQL, MariaDB or PostgreSQL
server; they are skipped unless DB_BACKUP_IT_DRIVER is set:
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Credits
License
The MIT License (MIT). Please see License File for more information.
All versions of database-backup-laravel with dependencies
illuminate/console Version ^11.0|^12.0|^13.0
illuminate/contracts Version ^11.0|^12.0|^13.0
illuminate/database Version ^11.0|^12.0|^13.0
illuminate/filesystem Version ^11.0|^12.0|^13.0
illuminate/support Version ^11.0|^12.0|^13.0
symfony/process Version ^7.0|^8.0