mirko-pagliai / cakephp-database-backup
Database Backup plugin for CakePHP
Installs: 20 154
Dependents: 1
Suggesters: 0
Security: 0
Stars: 19
Watchers: 5
Forks: 3
Open Issues: 3
Type:cakephp-plugin
Requires
- php: >=8.1
- ext-fileinfo: *
- cakephp/cakephp: ^5.0
- symfony/finder: ^6.0|^7.1
- symfony/process: ^6.0|^7.1.7
Requires (Dev)
- cakephp/cakephp-codesniffer: ^5.0
- cakephp/migrations: ^4.0
- phpstan/phpstan: ^1.10.38
- phpunit/phpunit: ^10.1.0 <=10.5.3
- vimeo/psalm: ^5.15.0
- dev-master
- 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-develop
- dev-develop-test
- dev-dependabot/composer/symfony/process-7.1.7
- dev-cakephp4
- dev-cakephp3
This package is auto-updated.
Last update: 2024-12-18 18:56:12 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.
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 Cookbook.
Simply, you can execute the shell command to enable the plugin:
bin/cake plugin load DatabaseBackup
This would update your application's bootstrap method.
By default the plugin uses the APP/backups
directory to save the backups
files. So you have to create the directory and make it writable:
$ mkdir backups/ && chmod 775 backups/
If you want to use a different directory, read the Configuration section.
Installation on older CakePHP and PHP versions
Recent packages and the master branch require at least CakePHP 5.0 and PHP 8.1 and the current development of the code
is based on these and later versions of CakePHP and PHP.
However, there are still some branches compatible with previous versions of PHP.
For PHP 7.4 and CakePHP 4.0 later
Instead, the cakephp4 branch requires at least PHP
>=7.4.0
and CakePHP ^4.0
.
In this case, you can install the package as well:
$ composer require --prefer-dist mirko-pagliai/cakephp-database-backup:dev-cakephp4
Note that the cakephp4
branch will no longer be updated as of January 05, 2024,
except for security patches, and it matches the
2.12.3 version.
For CakePHP 3.0 and PHP 5.6 or later
Instead, the cakephp3 branch requires at least PHP
>=5.6 <7.4
and CakePHP ^3.5.1
.
In this case, you can install the package as well:
$ composer require --prefer-dist mirko-pagliai/cakephp-database-backup:dev-cakephp3
Note that the cakephp3
branch will no longer be updated as of April 29, 2021,
except for security patches, and it matches the
2.8.5 version.
Requirements
DatabaseBackup requires:
mysql
andmysqldump
for MySql databases;pg_dump
andpg_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.
Please forward, remember that the database user must have the correct
permissions (for example, for mysql
the user must have the LOCK TABLES
permission).
Configuration
The plugin uses some configuration parameters. See our wiki:
If you want to send backup files by email, remember to set up your application correctly so that it can send emails. For more information on how to configure your application, see the Cookbook.
How to use
See our wiki:
- Export backups as cron jobs
- How to use the BackupExport utility
- How to use the BackupImport utility
- How to use the BackupManager utility
- How to use the BackupShell
And refer to our API.
Testing
Tests are run for only one driver at a time, by default mysql
.
To choose another driver to use, you can set the driver_test
environment variable before running phpunit
.
For example:
driver_test=sqlite vendor/bin/phpunit driver_test=postgres vendor/bin/phpunit
Alternatively, you can set the db_dsn
environment variable, indicating the connection parameters. In this case, the driver type will still be detected automatically.
For example:
db_dsn=sqlite:///' . TMP . 'example.sq3 vendor/bin/phpunit
Versioning
For transparency and insight into our release cycle and to maintain backward compatibility, DatabaseBackup will be maintained under the Semantic Versioning guidelines.