Skip to content

Commit

Permalink
Merge pull request #94 from mirko-pagliai/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
mirko-pagliai authored Jun 6, 2023
2 parents bedbd57 + c2ce210 commit 7f52c20
Show file tree
Hide file tree
Showing 39 changed files with 928 additions and 883 deletions.
30 changes: 30 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,34 @@
# 2.x branch
## 2.12 branch
### 2.12.0
* added `AbstractBackupUtility::timeout()` method, so now `BackupExport`/`BackupImport` utilities have a method to set the
timeout for shell commands at runtime. Added `--timeout` option (short: `-t`) for `ExportCommand`/`ImportCommand`;
* the events (`Backup.beforeExport`, `Backup.afterExport`, `Backup.beforeImport`, `Backup.afterImport`, which remain
implemented by the driver classes) are directly dispatched by the `BackupExport::export()` and `BackupImport::import()`
methods, and no longer by the drivers themselves;
* added the `AbstractBackupUtility` abstract class that provides the code common to `BackupExport` and `BackupImport`,
with the new `AbstractBackupUtility::__get()` magic method for reading `BackupExport`/`BackupImport` properties;
* removed `$Driver` public property for `BackupExport`/`BackupImport` and added `AbstractBackupUtility::getDriver()` method;
* the abstract `Driver` class has become `AbstractDriver` and no longer takes a connection as constructor argument, but
directly uses the one set by the configuration. The old `Driver::_exec()` method has been moved and has become
`AbstractBackupUtility::getProcess()`. The old `Driver::export()` and `Driver::import()` methods no longer exist and
their code has been "absorbed" into the `BackupExport::export()` and `BackupImport::import()` methods;
* `BackupTrait::getDriver()` method has become `AbstractBackupUtility::getDriver()`;
* `BackupTrait::getDriverName()` and `AbstractBackupUtility::getDriver()` no longer accept a connection as argument, but
directly use the one set by the configuration;
* the `BackupExport::export()` and `BackupImport::import()` methods can return the filename path on success or `false`
if the `Backup.beforeExport`/`Backup.beforeImport` events are stopped;
* `Driver::_getExecutable()`, `Driver::_getExportExecutable()` and `Driver::_getImportExecutable()` have become
`Driver::getExecutable()`, `Driver::getExportExecutable()` and `Driver::getImportExecutable()`;
* the `Driver::getConfig()` method no longer accepts `null` as argument, but only a string as key, since there is no
need to return the whole configuration;
* `MySql::getAuthFile()` method has become `getAuthFilePath()`, to be more understandable;
* `MySql::deleteAuthFile()` method returns void (there is no need for it to return anything);
* removed useless `TestCase::getMockForAbstractDriver()` method;
* removed useless `BackupExport::$config` property;
* improved the `ExportCommand` class;
* completely improved the `BackupImportTest` tests.

## 2.11 branch
### 2.11.1
* added the `DatabaseBackup.processTimeout` configuration, which allows you to set a timeout for commands that will be
Expand Down
3 changes: 2 additions & 1 deletion config/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@

//Writes default configuration values
$defaults = [
'DatabaseBackup.connection' => 'default',
'DatabaseBackup.chmod' => 0664,
'DatabaseBackup.connection' => 'default',
'DatabaseBackup.processTimeout' => 60,
'DatabaseBackup.target' => ROOT . 'backups',
'DatabaseBackup.mysql.export' => '{{BINARY}} --defaults-file={{AUTH_FILE}} {{DB_NAME}}',
'DatabaseBackup.mysql.import' => '{{BINARY}} --defaults-extra-file={{AUTH_FILE}} {{DB_NAME}}',
Expand Down
10 changes: 10 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,13 @@ parameters:
count: 1
path: tests/TestCase/BackupTraitTest.php

-
message: "#^Access to an undefined property DatabaseBackup\\\\Utility\\\\BackupExport\\:\\:\\$noExistingProperty\\.$#"
count: 1
path: tests/TestCase/Utility/BackupExportAndImportTest.php

-
message: "#^Expression \"\\$this\\-\\>BackupExport\\-\\>noExistingProperty\" on a separate line does not do anything\\.$#"
count: 1
path: tests/TestCase/Utility/BackupExportAndImportTest.php

15 changes: 10 additions & 5 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="4.x-dev@">
<file src="src/Driver/Mysql.php">
<RedundantPropertyInitializationCheck occurrences="2">
<code>$this-&gt;auth</code>
<code>TMP . uniqid('auth')</code>
</RedundantPropertyInitializationCheck>
</file>
<file src="src/TestSuite/DriverTestCase.php">
<TypeDoesNotContainType occurrences="1">
<code>empty($this-&gt;Driver)</code>
</TypeDoesNotContainType>
</file>
<file src="src/Utility/BackupExport.php">
<RedundantPropertyInitializationCheck occurrences="2">
<code>$this-&gt;defaultExtension</code>
<code>$this-&gt;extension</code>
</RedundantPropertyInitializationCheck>
<file src="src/Utility/AbstractBackupUtility.php">
<TypeDoesNotContainType occurrences="1">
<code>empty($this-&gt;Driver)</code>
</TypeDoesNotContainType>
</file>
<file src="src/Utility/BackupManager.php">
<TooManyTemplateParams occurrences="1">
Expand Down
118 changes: 67 additions & 51 deletions resources/locales/database_backup.pot
Original file line number Diff line number Diff line change
Expand Up @@ -4,161 +4,177 @@
#, fuzzy
msgid ""
msgstr ""
"POT-Creation-Date: 2019-12-18 16:44+0100\n"
"POT-Creation-Date: 2023-06-06 16:05+0200\n"
"PO-Revision-Date: YYYY-mm-DD HH:MM+ZZZZ\n"
"Last-Translator: NAME <EMAIL@ADDRESS>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"

#: BackupTrait.php:56
msgid "Binary for `{0}` could not be found. You have to set its path manually"
msgstr ""

#: BackupTrait.php:104
msgid "The `{0}` driver does not exist"
msgstr ""

#: Command/DeleteAllCommand.php:34
#: ./home/mirko/Libs/Plugins/cakephp-database-backup/src/Command/DeleteAllCommand.php:36
msgid "Deletes all database backups"
msgstr ""

#: Command/DeleteAllCommand.php:52
#: Command/RotateCommand.php:62
#: ./home/mirko/Libs/Plugins/cakephp-database-backup/src/Command/DeleteAllCommand.php:53
#: ./home/mirko/Libs/Plugins/cakephp-database-backup/src/Command/RotateCommand.php:64
msgid "No backup has been deleted"
msgstr ""

#: Command/DeleteAllCommand.php:58
#: Command/RotateCommand.php:68
#: ./home/mirko/Libs/Plugins/cakephp-database-backup/src/Command/DeleteAllCommand.php:59
#: ./home/mirko/Libs/Plugins/cakephp-database-backup/src/Command/RotateCommand.php:70
msgid "Backup `{0}` has been deleted"
msgstr ""

#: Command/DeleteAllCommand.php:61
#: Command/RotateCommand.php:71
#: ./home/mirko/Libs/Plugins/cakephp-database-backup/src/Command/DeleteAllCommand.php:62
#: ./home/mirko/Libs/Plugins/cakephp-database-backup/src/Command/RotateCommand.php:73
msgid "Deleted backup files: {0}"
msgstr ""

#: Command/ExportCommand.php:37
#: ./home/mirko/Libs/Plugins/cakephp-database-backup/src/Command/ExportCommand.php:39
msgid "Exports a database backup"
msgstr ""

#: Command/ExportCommand.php:41
#: ./home/mirko/Libs/Plugins/cakephp-database-backup/src/Command/ExportCommand.php:43
msgid "Compression type. By default, no compression will be used"
msgstr ""

#: Command/ExportCommand.php:45
msgid "Filename. It can be an absolute path and may contain patterns. The compression type will be automatically setted"
#: ./home/mirko/Libs/Plugins/cakephp-database-backup/src/Command/ExportCommand.php:47
msgid "Filename. It can be an absolute path and may contain patterns. The compression type will be automatically set"
msgstr ""

#: Command/ExportCommand.php:50
#: ./home/mirko/Libs/Plugins/cakephp-database-backup/src/Command/ExportCommand.php:52
msgid "Rotates backups. You have to indicate the number of backups you want to keep. So, it will delete all backups that are older. By default, no backup will be deleted"
msgstr ""

#: Command/ExportCommand.php:56
#: ./home/mirko/Libs/Plugins/cakephp-database-backup/src/Command/ExportCommand.php:58
msgid "Sends the backup file via email. You have to indicate the recipient's email address"
msgstr ""

#: Command/ExportCommand.php:94
#: ./home/mirko/Libs/Plugins/cakephp-database-backup/src/Command/ExportCommand.php:63
#: ./home/mirko/Libs/Plugins/cakephp-database-backup/src/Command/ImportCommand.php:45
msgid "Timeout for shell commands. Default value: {0} seconds"
msgstr ""

#: ./home/mirko/Libs/Plugins/cakephp-database-backup/src/Command/ExportCommand.php:101
#: ./home/mirko/Libs/Plugins/cakephp-database-backup/src/Command/ImportCommand.php:74
msgid "The `{0}` event stopped the operation"
msgstr ""

#: ./home/mirko/Libs/Plugins/cakephp-database-backup/src/Command/ExportCommand.php:102
msgid "Backup `{0}` has been exported"
msgstr ""

#: Command/ImportCommand.php:35
#: ./home/mirko/Libs/Plugins/cakephp-database-backup/src/Command/ImportCommand.php:39
msgid "Imports a database backup"
msgstr ""

#: Command/ImportCommand.php:37
#: Command/SendCommand.php:38
#: ./home/mirko/Libs/Plugins/cakephp-database-backup/src/Command/ImportCommand.php:41
#: ./home/mirko/Libs/Plugins/cakephp-database-backup/src/Command/SendCommand.php:40
msgid "Filename. It can be an absolute path"
msgstr ""

#: Command/ImportCommand.php:57
#: ./home/mirko/Libs/Plugins/cakephp-database-backup/src/Command/ImportCommand.php:75
msgid "Backup `{0}` has been imported"
msgstr ""

#: Command/IndexCommand.php:36
#: ./home/mirko/Libs/Plugins/cakephp-database-backup/src/Command/IndexCommand.php:38
msgid "Lists database backups"
msgstr ""

#: Command/IndexCommand.php:53
#: ./home/mirko/Libs/Plugins/cakephp-database-backup/src/Command/IndexCommand.php:54
msgid "Backup files found: {0}"
msgstr ""

#: Command/IndexCommand.php:60
#: ./home/mirko/Libs/Plugins/cakephp-database-backup/src/Command/IndexCommand.php:60
msgid "Filename"
msgstr ""

#: Command/IndexCommand.php:61
#: ./home/mirko/Libs/Plugins/cakephp-database-backup/src/Command/IndexCommand.php:61
msgid "Extension"
msgstr ""

#: Command/IndexCommand.php:62
#: ./home/mirko/Libs/Plugins/cakephp-database-backup/src/Command/IndexCommand.php:62
msgid "Compression"
msgstr ""

#: Command/IndexCommand.php:63
#: ./home/mirko/Libs/Plugins/cakephp-database-backup/src/Command/IndexCommand.php:63
msgid "Size"
msgstr ""

#: Command/IndexCommand.php:64
#: ./home/mirko/Libs/Plugins/cakephp-database-backup/src/Command/IndexCommand.php:64
msgid "Datetime"
msgstr ""

#: Command/RotateCommand.php:35
#: ./home/mirko/Libs/Plugins/cakephp-database-backup/src/Command/RotateCommand.php:37
msgid "Rotates backups"
msgstr ""

#: Command/RotateCommand.php:37
#: ./home/mirko/Libs/Plugins/cakephp-database-backup/src/Command/RotateCommand.php:39
msgid "Number of backups you want to keep. So, it will delete all backups that are older"
msgstr ""

#: Command/SendCommand.php:35
#: ./home/mirko/Libs/Plugins/cakephp-database-backup/src/Command/SendCommand.php:37
msgid "Send a database backup via mail"
msgstr ""

#: Command/SendCommand.php:42
#: ./home/mirko/Libs/Plugins/cakephp-database-backup/src/Command/SendCommand.php:44
msgid "Recipient's email address"
msgstr ""

#: Command/SendCommand.php:62
#: ./home/mirko/Libs/Plugins/cakephp-database-backup/src/Command/SendCommand.php:64
msgid "Backup `{0}` was sent via mail"
msgstr ""

#: Console/Command.php:38
#: ./home/mirko/Libs/Plugins/cakephp-database-backup/src/Console/Command.php:39
msgid "Connection: {0}"
msgstr ""

#: Console/Command.php:39
#: ./home/mirko/Libs/Plugins/cakephp-database-backup/src/Console/Command.php:40
msgid "Driver: {0}"
msgstr ""

#: Driver/Driver.php:185
#: Driver/Driver.php:228
msgid "Failed with exit code `{0}`"
#: ./home/mirko/Libs/Plugins/cakephp-database-backup/src/Console/Command.php:43
msgid "Timeout for shell commands: {0} seconds"
msgstr ""

#: Utility/BackupExport.php:119
#: ./home/mirko/Libs/Plugins/cakephp-database-backup/src/Utility/AbstractBackupUtility.php:83
msgid "The `{0}` driver does not exist"
msgstr ""

#: ./home/mirko/Libs/Plugins/cakephp-database-backup/src/Utility/BackupExport.php:75
msgid "Invalid compression type"
msgstr ""

#: Utility/BackupExport.php:155
#: ./home/mirko/Libs/Plugins/cakephp-database-backup/src/Utility/BackupExport.php:106
msgid "File `{0}` already exists"
msgstr ""

#: Utility/BackupExport.php:160
#: Utility/BackupImport.php:66
#: ./home/mirko/Libs/Plugins/cakephp-database-backup/src/Utility/BackupExport.php:109
msgid "Invalid `{0}` file extension"
msgstr ""

#: ./home/mirko/Libs/Plugins/cakephp-database-backup/src/Utility/BackupExport.php:176
msgid "Export failed with error message: `{0}`"
msgstr ""

#: ./home/mirko/Libs/Plugins/cakephp-database-backup/src/Utility/BackupImport.php:38
msgid "Invalid file extension"
msgstr ""

#: Utility/BackupImport.php:87
#: ./home/mirko/Libs/Plugins/cakephp-database-backup/src/Utility/BackupImport.php:59
msgid "You must first set the filename"
msgstr ""

#: Utility/BackupManager.php:100
#: ./home/mirko/Libs/Plugins/cakephp-database-backup/src/Utility/BackupImport.php:73
msgid "Import failed with error message: `{0}`"
msgstr ""

#: ./home/mirko/Libs/Plugins/cakephp-database-backup/src/Utility/BackupManager.php:94
msgid "Invalid rotate value"
msgstr ""

#: Utility/BackupManager.php:128
#: ./home/mirko/Libs/Plugins/cakephp-database-backup/src/Utility/BackupManager.php:117
msgid "Database backup {0} from {1}"
msgstr ""

Loading

0 comments on commit 7f52c20

Please sign in to comment.