mirko-pagliai / cakephp-database-backup
Database Backup plugin for CakePHP
Installs: 24 701
Dependents: 0
Suggesters: 0
Security: 0
Stars: 23
Watchers: 3
Forks: 3
Open Issues: 1
Type:cakephp-plugin
pkg:composer/mirko-pagliai/cakephp-database-backup
Requires
- php: >=8.4
- cakephp/cakephp: ^5.2.10
- league/container: ^4.2.3|^5.1
- symfony/filesystem: ^6.4.1|^7.2
- symfony/process: ^7.1.7
Requires (Dev)
- cakedc/cakephp-phpstan: ^4.0
- cakephp/cakephp-codesniffer: ^5.3
- cakephp/migrations: ^4.0
- mockery/mockery: ^1.6.10
- phpunit/phpunit: ^10.5.31 || ^11.2.7 || ^12.1
- symfony/finder: ^6.0|^7.2
- 3.0.x-dev
- 3.0.3
- 3.0.2
- 3.0.1
- 3.0.0
- 3.0.0-RC2
- 3.0.0-RC1
- 3.0.0-beta1
- 2.15.x-dev
- 2.15.3
- 2.15.2
- 2.15.1
- 2.15.0
- 2.14.x-dev
- 2.14.4
- 2.14.3
- 2.14.2
- 2.14.1
- 2.14.0
- 2.13.6
- 2.13.5
- 2.13.4
- 2.13.3
- 2.13.2
- 2.13.1
- 2.13.0
- 2.12.3
- 2.12.2
- 2.12.1
- 2.12.0
- 2.11.1
- 2.11.0
- 2.10.2
- 2.10.1
- 2.10.0-beta1
- 2.9.2
- 2.9.1
- 2.9.0
- 2.8.6
- 2.8.5
- 2.8.4
- 2.8.3
- 2.8.2
- 2.8.1
- 2.8.0
- 2.7.1
- 2.7.0
- 2.6.6
- 2.6.5
- 2.6.4
- 2.6.3
- 2.6.2
- 2.6.1
- 2.6.0
- 2.5.1
- 2.5.0
- 2.4.0
- 2.3.0
- 2.2.0
- 2.1.4
- 2.1.3
- 2.1.2
- 2.1.1
- 2.1.0
- 2.0.0
- 1.1.0
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- dev-3.0.x-docker
- dev-3.0.x-docker-ci-actions
- dev-3.0.x-docker-test
- dev-3.0.x-mariadb
- dev-2.15.x-dev
This package is auto-updated.
Last update: 2026-01-15 13:48:33 UTC
README
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: even a coffee is enough! Thank you.
Requirements
DatabaseBackup requires:
mariadbandmariadb-dumpfor MariaDB/MySql databases (if you still usemysql/mysqldump, see here);pg_dumpandpg_restorefor Postgres databases;sqlite3for 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:
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.
You can execute the shell command to enable the plugin:
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.15versions, which require at least CakePHP5.0and PHP8.1;- tag
cakephp4, which requires at least PHP>=7.4.0and CakePHP^4.0.
This tag no longer receives any updates as of January 5, 2024, and roughly coincides with what2.12.3version was. - tag
cakephp3, which requires at least PHP>=5.6 <7.4and CakePHP^3.5.1.
This tag no longer receives any updates as of April 29, 2021, and roughly coincides with what2.8.5version 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.
Before opening an issue, check this list of common issues.
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):
vendor/bin/phpunit --testsuite=real-drivers
Continuous integration (CI) workflows 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:
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.