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

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

codexshaper/database-backup-restore
===================================

Database Backup and Restore

v1.1(6y ago)1720.5k7[2 PRs](https://github.com/Codexshaper/database-backup-restore/pulls)1MITPHPPHP ^7.2

Since Dec 26Pushed 1y ago3 watchersCompare

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

READMEChangelog (2)Dependencies (2)Versions (4)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)[![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

35

—

LowBetter than 80% of packages

Maintenance30

Infrequent updates — may be unmaintained

Popularity31

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 91.2% 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 ~5 days

Total

2

Last Release

2329d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/88afdef32d0b9f6870f60d470bd66609c03fa02643393a7ee4c4de50dc390e3d?d=identicon)[Codexshaper](/maintainers/Codexshaper)

---

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

---

Tags

backupdatabase-backupdumpdumpermongodbmysqlpgsqlrestoresqlite3mysqlsqlitepgsqlmongodbdumperdatabsedatabse-backupdatabse-restore

###  Code Quality

TestsPHPUnit

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/codexshaper-database-backup-restore/health.svg)](https://phpackages.com/packages/codexshaper-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)[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)[vcian/laravel-db-auditor

Database DB Auditor provide leverage to audit your MySql,sqlite, PostgreSQL database standards and also provide options to add constraints in table.

28535.1k1](/packages/vcian-laravel-db-auditor)

PHPackages © 2026

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