adachsoft / data-backup-http-target
PSR-18 HTTP backup target for remote data backup APIs.
Package info
gitlab.com/a.adach/data-backup-http-target
pkg:composer/adachsoft/data-backup-http-target
Requires
- php: ^8.3
- adachsoft/data-backup-contracts: ^0.2
- psr/http-client: ^1
- psr/http-factory: ^1
- psr/http-message: ^1 || ^2
Requires (Dev)
- adachsoft/data-backup: ^0.3
- adachsoft/php-code-style: ^0.8.0
- friendsofphp/php-cs-fixer: ^3.95
- nyholm/psr7: ^1.8
- 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
adachsoft/data-backup-http-target provides a PSR-18 implementation of BackupTargetInterface for systems exposing the adachsoft/data-backup-symfony-bundle HTTP backup API. It lets BackupService download a remote archive and save it to a local archive storage, where the local service can apply its own retention policy.
Installation
composer require adachsoft/data-backup-http-target
Provide a PSR-18 HTTP client and PSR-17 request and stream factories from your application. No HTTP framework is required by this library.
Features
- Implements
BackupTargetInterfaceusing a PSR-18 HTTP client. - Creates remote archives and exposes them as archive readers for local storage.
- Supports configurable API endpoints, request headers, and remote storage selection.
- Reports HTTP and response-format errors with request context.
Requirements
- PHP 8.3 or later.
- A PSR-18 HTTP client and PSR-17 request and stream factories.
- A PSR-7 message implementation compatible with those interfaces.
adachsoft/data-backupwhen using the target withBackupService.
Usage with BackupService
use AdachSoft\DataBackup\Service\BackupService;
use AdachSoft\DataBackupContracts\Collection\DataSourceIdCollection;
use AdachSoft\DataBackupContracts\Dto\ExportRequest;
use AdachSoft\DataBackupContracts\ValueObject\LabelMap;
use AdachSoft\DataBackupHttpTarget\HttpBackupTarget;
use AdachSoft\DataBackupHttpTarget\HttpBackupTargetConfig;
$target = new HttpBackupTarget(
$httpClient,
$requestFactory,
$streamFactory,
$archiveFormat,
new HttpBackupTargetConfig(
baseUrl: 'https://task-api.example.com',
headers: ['X-API-KEY' => $apiKey],
remoteStorage: 'nightly',
),
);
$backupService = new BackupService(
$archiveFormat,
$streamFactory,
$retentionPolicy,
$eventListener,
$clock,
);
$reference = $backupService->backup(
$target,
$localArchiveStorage,
new ExportRequest(new DataSourceIdCollection(), new LabelMap(['schedule' => 'hourly'])),
);
An empty source collection requests all remote sources. The configured headers are sent with each request. When remoteStorage is set, it is included in the archive creation request and in the download URL.
Remote restoration
Import is not supported by this client. Restore an archive on the remote system using POST /api/v1/backup/import or run the data-backup:restore command there.