adachsoft / data-backup-action
An automation action for exporting named data backup targets to configured archive storage.
Requires
- php: ^8.3
- adachsoft/action-contracts: ^0.1.2
- adachsoft/data-backup-contracts: ^0.2
Requires (Dev)
- adachsoft/data-backup: ^0.3
- adachsoft/php-code-style: ^0.8.0
- friendsofphp/php-cs-fixer: ^3.95
- phpstan/phpstan: ^2.3
- phpunit/phpunit: ^13
- rector/rector: ^2.9
- symplify/phpstan-rules: ^14.19
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Composer package: adachsoft/data-backup-action.
This library integrates data backup operations into an automation host. It exposes a data_backup.run action that selects a configured backup target and archive storage, then delegates the export to the data backup service.
Main capabilities
- Publishes the
data_backup.runaction type with configured target and storage choices. - Supports selecting data source IDs and attaching string labels to an export.
- Defaults to the first configured archive storage and marks every export with the
trigger=automationlabel. - Returns the archive and storage identifiers or a failure result for invalid parameters and failed exports.
Requirements
- PHP
^8.3 adachsoft/action-contracts:^0.1.2adachsoft/data-backup-contracts:^0.2
Installation
composer require adachsoft/data-backup-action
Usage
An internal automation action that backs up a named BackupTargetInterface to a named ArchiveStorageInterface through BackupServiceInterface.
The action type is data_backup.run and is intended to be registered in the host application's automation container.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
target | enum | yes | Name of the configured backup target. |
storage | enum | no | Name of the archive storage; defaults to the first configured storage. |
sources | string | no | Comma-separated data source IDs. An empty value exports all sources. |
labels | JSON object | no | Optional string-to-string labels. The handler always sets trigger to automation. |
The result output contains the configured target and storage names, the archiveId, and the storage's storageId.
Symfony registration
The host application supplies implementations of BackupTargetInterface, ArchiveStorageInterface, and BackupServiceInterface. The example uses application-specific tags to inject the named targets and storages into both action services.
# config/services.yaml
services:
_defaults:
autowire: true
AdachSoft\DataBackupContracts\Contract\BackupServiceInterface:
alias: App\Backup\BackupService
app.data_backup_action.target.task_api:
class: AdachSoft\DataBackupAction\NamedBackupTarget
arguments:
$name: task_api
$target: '@App\Backup\TaskApiBackupTarget'
tags: ['app.data_backup_action.target']
app.data_backup_action.storage.nas:
class: AdachSoft\DataBackupAction\NamedArchiveStorage
arguments:
$name: nas
$storage: '@App\Backup\NasArchiveStorage'
tags: ['app.data_backup_action.storage']
AdachSoft\DataBackupAction\ActionType\DataBackupRunActionTypeProvider:
arguments:
$targets: !tagged_iterator app.data_backup_action.target
$storages: !tagged_iterator app.data_backup_action.storage
tags:
- { name: adachsoft_automation.action_type_provider }
AdachSoft\DataBackupAction\Handler\DataBackupRunActionHandler:
arguments:
$targets: !tagged_iterator app.data_backup_action.target
$storages: !tagged_iterator app.data_backup_action.storage
tags:
- { name: adachsoft_automation.action_handler }
Register a schedule under adachsoft_automation.schedules to run the action every hour:
# config/packages/adachsoft_automation.yaml
adachsoft_automation:
schedules:
task_api_backup:
rule:
type: repeating
frequency: hourly
interval: 1
actions:
- type: data_backup.run
params: { target: task_api }