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

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

michelmelo/database-backup-restore
==================================

Database Backup and Restore

1.1(4y ago)011MITPHPPHP ^7.2|^8.0

Since Sep 17Pushed 4y ago1 watchersCompare

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

READMEChangelog (1)Dependencies (2)Versions (2)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 codexshaper/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

24

—

LowBetter than 31% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

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

Unknown

Total

1

Last Release

1749d ago

### Community

Maintainers

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

---

Tags

mysqlsqlitepgsqlmongodbdumperdatabsedatabse-backupdatabse-restore

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[doctrine/dbal

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

9.7k605.0M6.8k](/packages/doctrine-dbal)[codexshaper/database-backup-restore

Database Backup and Restore

1920.6k1](/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.

5892.7M55](/packages/aura-sql)[aura/sqlquery

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

4883.1M37](/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.

117548.2k6](/packages/apix-cache)[phpbu/phpbu

PHP Backup utility.

1.3k95.3k4](/packages/phpbu-phpbu)

PHPackages © 2026

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