PHPackages                             rguj/dbr - 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. rguj/dbr

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

rguj/dbr
========

Database Backup and Restore v2

1.0.0(3y ago)071MITPHPPHP ^7.0|^7.1|^8.0|^8.1

Since Oct 18Pushed 3y ago1 watchersCompare

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

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

[![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)

database-backup-restore
=======================

[](#database-backup-restore)

Database Backup &amp; Restore

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();

```

Authors
-------

[](#authors)

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

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 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity55

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

Unknown

Total

1

Last Release

1305d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0495fb7c2f8991e163e67ff67c7d506eb3eb1677437f0a15454dcd41473229c0?d=identicon)[rguj](/maintainers/rguj)

---

Top Contributors

[![rguj](https://avatars.githubusercontent.com/u/69418277?v=4)](https://github.com/rguj "rguj (1 commits)")

---

Tags

mysqlsqlitepgsqlmongodbdumperdatabsedatabse-backupdatabse-restore

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/rguj-dbr/health.svg)

```
[![Health](https://phpackages.com/badges/rguj-dbr/health.svg)](https://phpackages.com/packages/rguj-dbr)
```

###  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)
