PHPackages                             ahmard/database-backup - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. ahmard/database-backup

ActiveProject[Database &amp; ORM](/categories/database)

ahmard/database-backup
======================

Handles database backup

0.1.2(2y ago)3231MITPHPPHP ^8.2

Since Jul 26Pushed 2y ago1 watchersCompare

[ Source](https://github.com/Ahmard/database-backup)[ Packagist](https://packagist.org/packages/ahmard/database-backup)[ RSS](/packages/ahmard-database-backup/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (4)Versions (4)Used By (0)

Database Backup
===============

[](#database-backup)

Takes database backup after certain interval

Installation
------------

[](#installation)

`composer require ahmard/database-backup`

Usage
-----

[](#usage)

```
use DatabaseBackup\Backup;
use DatabaseBackup\Helpers\Console;

// Backup Class (NucleusBackup.php)
class NucleusBackup extends AbstractBackup
{
    protected bool $sendMailOnError = false;
    protected bool $sendMailOnSuccess = false;

    public function interval(): int
    {
        return 2_000;
    }

    public function filePath(): string
    {
        return sprintf('%s/nucleus-%s.sql', dirname(__DIR__, 2), uniqid());
    }

    public function onSuccess(string $path, callable $done): void
    {
        $done();
        Console::info('nucleus backup completed');
        unlink($path);
    }

    public function connection(): DatabaseConnection
    {
        return new DatabaseConnection(
            driver: DatabaseDriver::MYSQL,
            host: 'localhost',
            username: 'root',
            password: '1234',
            database: 'nucleus'
        );
    }
}

// Runner (run.php)
use Swoole\Runtime;
use DatabaseBackup\Backup;
use DatabaseBackup\Helpers\Console;

require __DIR__ . '/vendor/autoload.php';

Runtime::enableCoroutine(SWOOLE_HOOK_ALL);

Console::writeln("Backup service started");

// Run backups
Backup::new()->start([NucleusBackup::class]);
```

### Mail Notification

[](#mail-notification)

```
use DatabaseBackup\Backup;

$receivers = [
    new MailReceiver(
        email: 'jane.doe@example.com',
        name: 'Jane Doe'
    ),
];

$smtp = new SmtpCredential(
    host: 'localhost',
    port: 8025,
    username: 'noreply@example.com',
    password: 'Password',
    auth: false
);

Backup::new()
    ->withSmtp($smtp)
    ->withMailReceivers($receivers)
    ->start([NucleusBackup::class]);
```

This library is **MIT Licenced**

Enjoy 😉

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

3

Last Release

1025d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2b69fe34bd6492697a19cd8f33bde7a381cab0b7f8c0a01dcc7505f482458887?d=identicon)[Ahmard](/maintainers/Ahmard)

---

Top Contributors

[![Ahmard](https://avatars.githubusercontent.com/u/44737217?v=4)](https://github.com/Ahmard "Ahmard (7 commits)")

###  Code Quality

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/ahmard-database-backup/health.svg)

```
[![Health](https://phpackages.com/badges/ahmard-database-backup/health.svg)](https://phpackages.com/packages/ahmard-database-backup)
```

###  Alternatives

[spatie/laravel-backup

A Laravel package to backup your application

6.0k21.8M191](/packages/spatie-laravel-backup)[spatie/laravel-db-snapshots

Quickly dump and load databases

1.2k2.8M20](/packages/spatie-laravel-db-snapshots)[phpauth/phpauth

A secure user authentication class for PHP websites, using a powerful password hashing system and attack blocking to keep your website and users secure.

894196.1k3](/packages/phpauth-phpauth)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
