PHPackages                             ayhome/database-backup-restore - 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. ayhome/database-backup-restore

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

ayhome/database-backup-restore
==============================

Database Backup and Restore

1.0.1(1y ago)05MITPHPPHP &gt;=7.2

Since Aug 28Pushed 1y agoCompare

[ Source](https://github.com/ayhome/database-backup-restore)[ Packagist](https://packagist.org/packages/ayhome/database-backup-restore)[ Docs](https://github.com/ayhome/database-backup-restore)[ RSS](/packages/ayhome-database-backup-restore/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (3)Used By (0)

[![License](https://camo.githubusercontent.com/1e1cb7bae9fc55a01fc5443d26e358dc21c129253bcfa9841db85c4f25aa2ecf/687474703a2f2f696d672e736869656c64732e696f2f3a6c6963656e73652d6d69742d626c75652e7376673f7374796c653d666c61742d737175617265)](http://badges.mit-license.org)[![Build Status](https://camo.githubusercontent.com/7100b8c9d07bcae06442db6cb45b66a3e9dc92735bc6c928418ff5de4b89d6db/68747470733a2f2f7472617669732d63692e6f72672f436f6465787368617065722f64617461626173652d6261636b75702d726573746f72652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Codexshaper/database-backup-restore)[![Quality Score](https://camo.githubusercontent.com/4f58f23f79aafe497e5db35843237ec297a6dc2fd4796f6571ffc479c7f30d5f/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f436f6465787368617065722f64617461626173652d6261636b75702d726573746f72652e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/Codexshaper/database-backup-restore)[![Latest Version on Packagist](https://camo.githubusercontent.com/b56b6a371ea95cd36c8e7f026c065e4803e9b1e24d8bcc104fcda6a2f10a5745/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f436f6465787368617065722f64617461626173652d6261636b75702d726573746f72652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/Codexshaper/database-backup-restore)

Description
===========

[](#description)

Database Backup &amp; Restore

[Documentation](https://codexshaper.github.io/docs/database-backup-restore/)

Authors
-------

[](#authors)

- **Md Abu Ahsan Basir** - [github](https://github.com/maab16)

Installation
============

[](#installation)

```
composer require ayhome/database-backup-restore

```

### MySql Dump *(Note: Mustbe installed `mysqldump` in your system)*

[](#mysql-dump-note-mustbe-installed-mysqldump-in-your-system)

```
$options    = [
    'host'            => 'HOST',
    'port'            => 'PORT',
    'dbName'          => 'DATABASE_NAME',
    'username'        => 'DATABASE_USERNAME',
    'password'        => 'DATABASE_PASSWORD',
    'destinationPath' => 'STORAGE_PATH_WITH_FILE_NAME', // /path/to/backups/mysql/dump
];

```

Use constructor with options

```
$dumper = new \CodexShaper\Dumper\Drivers\MysqlDumper($options);
$dumper->dump();

```

Use create method

```
\CodexShaper\Dumper\Drivers\MysqlDumper::create($options)->dump();

```

Dynamically

```
\CodexShaper\Dumper\Drivers\MysqlDumper::create()
  ->setHost($host)
  ->setPort($port)
  ->setDbName($database)
  ->setUserName($username)
  ->setPassword($password)
  ->setDestinationPath($destinationPath)
  ->dump();

```

Archive

```
\CodexShaper\Dumper\Drivers\MysqlDumper::create($options)
  ->useCompress("gzip") // This command apply gzip to zip
  ->dump();

```

### MySql Restore *(Note: Mustbe installed `mysql` in your system)*

[](#mysql-restore-note-mustbe-installed-mysql-in-your-system)

Restore from without archive

```
$dumper = new \CodexShaper\Dumper\Drivers\MysqlDumper($options);
$dumper->setRestorePath($restorePath); // /path/to/backups/mysql/dump.sql
$dumper->restore();

```

Restore from archive

```
\CodexShaper\Dumper\Drivers\MysqlDumper::create($options)
  ->useCompress("gunzip") // this command unzip the file
  ->setRestorePath($restorePath) // /path/to/backups/mysql/dump.sql.gz
  ->restore();

```

### PgSql Dump *(Note: Mustbe installed `pg_dump` in your system)*

[](#pgsql-dump-note-mustbe-installed-pg_dump-in-your-system)

```
$options    = [
    'host'            => 'HOST',
    'port'            => 'PORT',
    'dbName'          => 'DATABASE_NAME',
    'username'        => 'DATABASE_USERNAME',
    'password'        => 'DATABASE_PASSWORD',
    'destinationPath' => 'STORAGE_PATH_WITH_FILE_NAME', // /path/to/backups/pgsql/dump
];

```

Use constructor with options

```
$dumper = new \CodexShaper\Dumper\Drivers\PgsqlDumper($options);
$dumper->dump();

```

Use create method

```
\CodexShaper\Dumper\Drivers\PgsqlDumper::create($options)->dump();

```

Dynamically

```
\CodexShaper\Dumper\Drivers\PgsqlDumper::create()
  ->setHost($host)
  ->setPort($port)
  ->setDbName($database)
  ->setUserName($username)
  ->setPassword($password)
  ->setDestinationPath($destinationPath)
  ->dump();

```

Archive

```
\CodexShaper\Dumper\Drivers\PgsqlDumper::create($options)
  ->useCompress("gzip") // This command apply gzip to zip
  ->dump();

```

### PgSql Restore *(Note: Mustbe installed `psql` in your system)*

[](#pgsql-restore-note-mustbe-installed-psql-in-your-system)

Restore from without archive

```
$dumper = new \CodexShaper\Dumper\Drivers\PgsqlDumper($options);
$dumper->setRestorePath($restorePath); // /path/to/backups/pgsql/dump.sql
$dumper->restore();

```

Restore from archive

```
\CodexShaper\Dumper\Drivers\PgsqlDumper::create($options)
  ->useCompress("gunzip") // this command unzip the file
  ->setRestorePath($restorePath) // /path/to/backups/pgsql/dump.sql.gz
  ->restore();

```

### Sqlite Dump *(Note: Mustbe installed `sqlite3` in your system)*

[](#sqlite-dump-note-mustbe-installed-sqlite3-in-your-system)

```
$options    = [
    'dbName'          => 'DATABASE_PATH', // /path/to/database.sqlite
    'destinationPath' => 'STORAGE_PATH_WITH_FILE_NAME', // /path/to/backups/sqlite/dump.sql
];

```

Use constructor

```
$dumper = new \CodexShaper\Dumper\Drivers\SqliteDumper($options);
$dumper->dump();

```

Use create method

```
\CodexShaper\Dumper\Drivers\SqliteDumper::create($options)->dump();

```

Set Dynamically

```
\CodexShaper\Dumper\Drivers\SqliteDumper::create()
  ->setDbName($database)
  ->setDestinationPath($destinationPath)
  ->dump();

```

Archive

```
\CodexShaper\Dumper\Drivers\SqliteDumper::create()
  ->setDbName($database)
  ->setDestinationPath($destinationPath)
  ->useCompress("gzip") // This command apply gzip to zip
  ->dump();

```

### Sqlite Restore *(Note: Mustbe installed `sqlite3` in your system)*

[](#sqlite-restore-note-mustbe-installed-sqlite3-in-your-system)

```
$options    = [
    'dbName'          => 'DATABASE_PATH', // /path/to/database.sqlite
    'restorePath' => 'RESTORE_PATH_WITH_FILE_NAME', // /path/to/backups/sqlite/dump.sql
];

```

Use Construct

```
$dumper = new \CodexShaper\Dumper\Drivers\SqliteDumper($options);
$dumper->restore();

```

Use Dynamic

```
\CodexShaper\Dumper\Drivers\SqliteDumper::create()
  ->setDbName($database)
  ->setRestorePath($restorePath)
  ->restore();

```

Restore From Archive

```
\CodexShaper\Dumper\Drivers\SqliteDumper::create()
  ->setDbName($database)
  ->setRestorePath($restorePath)
  ->useCompress("gunzip") // This command apply gzip to zip
  ->restore();

```

### MongoDB Dump *(Note: Mustbe installed `mongodump` in your system)*

[](#mongodb-dump-note-mustbe-installed-mongodump-in-your-system)

```
$options    = [
    'host'            => 'HOST',
    'port'            => 'PORT',
    'dbName'          => 'DATABASE_NAME',
    'username'        => 'DATABASE_USERNAME',
    'password'        => 'DATABASE_PASSWORD',
    'destinationPath' => 'STORAGE_PATH_WITH_FILE_NAME', // /path/to/backups/mongodb/dump
];

```

Use constructor with options

```
$dumper = new \CodexShaper\Dumper\Drivers\MongoDumper($options);
$dumper->dump();

```

Use create method

```
\CodexShaper\Dumper\Drivers\MongoDumper::create($options)->dump();

```

Dynamically

```
\CodexShaper\Dumper\Drivers\MongoDumper::create()
  ->setHost($host)
  ->setPort($port)
  ->setDbName($database)
  ->setUserName($username)
  ->setPassword($password)
  ->setDestinationPath($destinationPath)
  ->dump();

```

Archive

```
\CodexShaper\Dumper\Drivers\MongoDumper::create($options)
  ->useCompress("gzip") // This command will add --archive with --gzip
  ->dump();

```

#### Use URI

[](#use-uri)

```
$options = [
    'uri'             => $uri,
    "destinationPath" => $destinationPath, // /path/to/backups/mongodb/dump
];
$dumper = new \CodexShaper\Dumper\Drivers\MongoDumper($options);
$dumper->dump();

```

OR

```
\CodexShaper\Dumper\Drivers\MongoDumper::create(['uri' => $uri])
  ->setDestinationPath($destinationPath)
  ->dump()

```

Dynamic

```
\CodexShaper\Dumper\Drivers\MongoDumper::create()
  ->setUri($uri)
  ->setDestinationPath($destinationPath)
  ->dump()

```

Compress

```
\CodexShaper\Dumper\Drivers\MongoDumper::create(['uri' => $uri])
  ->useCompress("gzip")
  ->setDestinationPath($destinationPath)
  ->dump();

```

### MongoDB Restore *(Note: Mustbe installed `mongorestore` in your system)*

[](#mongodb-restore-note-mustbe-installed-mongorestore-in-your-system)

Restore from without archive

```
$dumper = new \CodexShaper\Dumper\Drivers\MongoDumper($options);
$dumper->setRestorePath($restorePath); // /path/to/backups/mongodb/dump
$dumper->restore();

```

Use URI

```
\CodexShaper\Dumper\Drivers\MongoDumper::create(['uri' => $uri])
    ->setRestorePath($restorePath)
    ->restore();

```

Restore from archive

```
\CodexShaper\Dumper\Drivers\MongoDumper::create($options)
  ->useCompress("gzip")
  ->setRestorePath($restorePath) // /path/to/backups/mongodb/dump.gz
  ->restore();

```

Restore from archive using URI

```
\CodexShaper\Dumper\Drivers\MongoDumper::create(['uri' => $uri])
  ->useCompress("gzip")
  ->setRestorePath($restorePath)
  ->restore();

```

### Set Dump Binary Path

[](#set-dump-binary-path)

```
// Same for other driver
\CodexShaper\Dumper\Drivers\MysqlDumper::create($options)
  ->setCommandBinaryPath($binaryPath) // /path/to/mysql/bin
  ->dump();

```

License
-------

[](#license)

- **[MIT license](http://opensource.org/licenses/mit-license.php)**
- Copyright 2019 © [CodexShaper](https://github.com/Codexshaper/database-backup-restore/blob/master/LICENSE).

###  Health Score

22

—

LowBetter than 23% of packages

Maintenance36

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity35

Early-stage or recently created project

 Bus Factor1

Top contributor holds 87.3% 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

2

Last Release

619d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0aad496bd3f3648f041ddebb82156f03473f73306ad0eb2193d9ceca7f17b806?d=identicon)[ayhome](/maintainers/ayhome)

---

Top Contributors

[![maab16](https://avatars.githubusercontent.com/u/20833514?v=4)](https://github.com/maab16 "maab16 (62 commits)")[![Codexshaper](https://avatars.githubusercontent.com/u/49456098?v=4)](https://github.com/Codexshaper "Codexshaper (6 commits)")[![ayhome](https://avatars.githubusercontent.com/u/490287?v=4)](https://github.com/ayhome "ayhome (3 commits)")

---

Tags

mysqlsqlitepgsqlmongodbdumperdatabsedatabse-backupdatabse-restore

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.

9.7k578.4M5.6k](/packages/doctrine-dbal)[codexshaper/database-backup-restore

Database Backup and Restore

1720.5k1](/packages/codexshaper-database-backup-restore)[aura/sql

A PDO extension that provides lazy connections, array quoting, query profiling, value binding, and convenience methods for common fetch styles. Because it extends PDO, existing code that uses PDO can use this without any changes to the existing code.

5632.5M43](/packages/aura-sql)[aura/sqlquery

Object-oriented query builders for MySQL, Postgres, SQLite, and SQLServer; can be used with any database connection library.

4572.9M34](/packages/aura-sqlquery)[apix/cache

A thin PSR-6 cache wrapper with a generic interface to various caching backends emphasising cache taggging and indexing to Redis, Memcached, PDO/SQL, APC and other adapters.

114542.8k6](/packages/apix-cache)[dg/adminer-custom

Customization for Adminer, the best database management tool written in PHP.

134765.7k16](/packages/dg-adminer-custom)

PHPackages © 2026

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