Skip to content
docsv0.1.1

BackupManager

Orchestrates one backup "run": a {@see DatabaseDumperInterface} dump plus a {@see StorageArchiver} archive, recorded as a `{id}.manifest.json` file in `$backupDir` alongside the `.sql`/`.tar.gz` it produced. {@see BackupCatalog} reads those manifests back; this class is the only writer of new ones. `run()` never throws: a failed dump or archive is caught and reported as a non-`ok` {@see BackupReport} instead, so a scheduled/cron caller always gets a report to act on rather than an uncaught exception mid-run.

BackupManager::__construct()

public function __construct(string $backupDir, Milpa\Ops\Backup\DatabaseDumperInterface $dumper, Milpa\Ops\Backup\StorageArchiver $archiver):

Parameters

Parameters of __construct()
NameTypeDescription
$backupDirstring
$dumperMilpa\Ops\Backup\DatabaseDumperInterface
$archiverMilpa\Ops\Backup\StorageArchiver

BackupManager::run()

public function run(string $id, string $createdAtIso): Milpa\Ops\Backup\BackupReport

Dump the database, archive storage, and write the manifest — all under `$id`. Always returns a {@see BackupReport}; a failure mid-run is captured in it (`ok: false`, `error` set) rather than propagated as an exception.

Parameters

Parameters of run()
NameTypeDescription
$idstring
$createdAtIsostring

BackupManager::restore()

public function restore(string $id): void

Restore the database and storage from a previously completed backup. Confirming this destructive action with the operator is the caller's job (the command), not this method's — by the time `restore()` runs, it executes unconditionally.

Parameters

Parameters of restore()
NameTypeDescription
$idstring

Throws

RuntimeException if `$id` has no manifest, or its database dump is missing