https://github.com/mirko-pagliai/cakephp-database-backup
DatabaseBackup is a CakePHP plugin to export, import and manage database backups
https://github.com/mirko-pagliai/cakephp-database-backup
backup backup-script backup-tool backup-utility cakephp cakephp-plugin database-backup mysql php postgresql sqlite
Last synced: 6 days ago
JSON representation
DatabaseBackup is a CakePHP plugin to export, import and manage database backups
- Host: GitHub
- URL: https://github.com/mirko-pagliai/cakephp-database-backup
- Owner: mirko-pagliai
- License: mit
- Created: 2017-06-22T18:38:58.000Z (almost 9 years ago)
- Default Branch: 3.0.x
- Last Pushed: 2026-02-01T08:24:19.000Z (3 months ago)
- Last Synced: 2026-03-09T16:59:34.467Z (about 2 months ago)
- Topics: backup, backup-script, backup-tool, backup-utility, cakephp, cakephp-plugin, database-backup, mysql, php, postgresql, sqlite
- Language: PHP
- Homepage:
- Size: 1.76 MB
- Stars: 24
- Watchers: 3
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
- awesome-cakephp - DatabaseBackup plugin - A plugin to to export, import and manage database backups. Currently, the plugin supports MySql, Postgres and Sqlite databases. (Miscellaneous)
README
# cakephp-database-backup
[](LICENSE.txt)
[](https://github.com/mirko-pagliai/cakephp-database-backup/actions/workflows/ci.yml)
[](https://codecov.io/gh/mirko-pagliai/cakephp-database-backup)
[](https://app.codacy.com/gh/mirko-pagliai/cakephp-database-backup/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
[](https://www.codefactor.io/repository/github/mirko-pagliai/cakephp-database-backup)
*DatabaseBackup* is a CakePHP plugin to export, import and manage database backups.
Currently, the plugin supports *MySql*, *Postgres* and *Sqlite* databases.
Did you like this plugin? Its development requires a lot of time for me.
Please consider the possibility of making [a donation](//paypal.me/mirkopagliai):
even a coffee is enough! Thank you.
[](//paypal.me/mirkopagliai)
## Requirements
*DatabaseBackup* requires:
* `mariadb` and `mariadb-dump` for *MariaDB*/*MySql* databases (if you still use `mysql`/`mysqldump`, [see here](https://github.com/mirko-pagliai/cakephp-database-backup/blob/3.0.x/docs/Common%20issues.md#transition-from-mysql-and-mysqldump-to-mariadb-and-mariadb-dump));
* `pg_dump` and `pg_restore` for *Postgres* databases;
* `sqlite3` for *Sqlite* databases.
**Optionally**, if you want to handle compressed backups, `bzip2` and `gzip` are
also required.
The installation of these binaries may vary depending on your operating system.
## Installation
You can install the plugin via composer:
```bash
composer require --prefer-dist mirko-pagliai/cakephp-database-backup
```
Then you have to load the plugin. For more information on how to load the plugin,
please refer to the [CakePHP documentation](https://book.cakephp.org/5/en/plugins.html#loading-a-plugin).
You can execute the shell command to enable the plugin:
```bash
bin/cake plugin load DatabaseBackup
```
This would update your application's bootstrap method.
### Installation on older CakePHP and PHP versions
Compared to the current installation requirements, some tags or branches are provided for those using older versions of
CakePHP and PHP:
- `2.15` versions, which require at least CakePHP `5.0` and PHP `8.1`;
- tag [`cakephp4`](https://github.com/mirko-pagliai/cakephp-database-backup/releases/tag/cakephp4), which requires at
least PHP `>=7.4.0` and CakePHP `^4.0`.
This tag no longer receives any updates as of January 5, 2024, and roughly coincides with what `2.12.3` version was.
- tag [`cakephp3`](https://github.com/mirko-pagliai/cakephp-database-backup/releases/tag/cakephp3), which requires at
least PHP `>=5.6 <7.4` and CakePHP `^3.5.1`.
This tag no longer receives any updates as of April 29, 2021, and roughly coincides with what `2.8.5` version was.
You can freely use these, even by downloading the source codes from the attached assets, but their functioning is
no longer guaranteed, especially regarding old dependencies that may no longer be available.
## Configuration and How to use
See [our documentation](/docs).
Before opening an issue, check this list of [common issues](docs/Common%20issues.md).
## Testing
Unlike previous versions, with the 3.x branch, thanks to the _Mockery_'s overloading and the (external) component
`Process` that actually takes care of executing the commands to export/import the databases, normally the tests do not
really use the database drivers and do not write or read files on the filesystem (i.e., everything is simulated).
The only exception is given by the class `DatabaseBackup\Test\TestCase\Utility\BackupExportAndImportTest`, which however
does not belong to the testsuite executed by default (it is therefore an optional test) and is marked with the attribute
`#[CoversNothing]`.
This test class, when executed, will test a real database export and import, using the `pdo_mysql`, `pdo_pgsql` and
`pdo_sqlite` PHP extensions, that is all the drivers and databases supported by the plugin.
You can test the class directly or the configured `real-drivers` testsuite ([see available testsuites](phpunit.xml.dist)):
```bash
vendor/bin/phpunit --testsuite=real-drivers
```
[Continuous integration (CI) workflows](https://github.com/mirko-pagliai/cakephp-database-backup/actions/workflows/ci.yml) must be run with `highest`/`lowest` dependencies and "without"/"only with"
real drivers and databases.
### Running tests with real database drivers (_Docker_)
Some tests require real database drivers and system binaries (e.g. `mysqldump`, `pg_dump`, `pg_restore`) and therefore
depend on the local environment configuration.
However, running these tests reliably requires properly configured database servers and matching system binaries.
For this reason, _Docker_ can be used to provide a predefined and controlled environment in which real-drivers tests can
be executed consistently.
#### Running real-drivers tests using Docker
From the project root:
```bash
docker compose -f docker/docker-compose.yml down -v
docker compose -f docker/docker-compose.yml build
docker compose -f docker/docker-compose.yml up -d
docker compose -f docker/docker-compose.yml exec php vendor/bin/phpunit --testsuite=real-drivers
```
This setup runs the real-drivers test suite against real MySQL/MariaDB and PostgreSQL servers, using their corresponding
dump/restore binaries, in a controlled environment.
## Versioning
For transparency and insight into our release cycle and to maintain backward
compatibility, *DatabaseBackup* will be maintained under the
[Semantic Versioning guidelines](http://semver.org).