M2: full backup runs (database, config, data) with occ and cron

BackupService starts a run per location (database dump in one
transaction, then config + data directory as a resumable file run),
stores the state in ngb_runs after every step, locks a run while a step
executes and records the snapshot. Previews, logs, updater backups and
per-user cache/uploads are excluded (TreeWalker now supports patterns).
BackupJob (every 5 min) starts the daily schedule and steps running runs
with a short budget under web cron and a long one under system cron.
occ: backup:run, backup:status, backup:list.

Tested on NC34/PostgreSQL: first run 128 files / 1 GiB in 64 s (443 MiB
uploaded to S3), unchanged second run 2 s / 0 bytes; a background run to
SFTP completed through cron.php.
This commit is contained in:
2026-10-02 00:53:50 +02:00
parent 9cefea019d
commit 2ab4b2e7d5
12 changed files with 693 additions and 15 deletions
+43
View File
@@ -0,0 +1,43 @@
<?php
declare(strict_types=1);
// SPDX-FileCopyrightText: 2026 Dillard Blom
// SPDX-License-Identifier: AGPL-3.0-or-later
namespace OCA\NgBackup\Db;
use OCP\AppFramework\Db\Entity;
/**
* @method int getTargetId()
* @method void setTargetId(int $v)
* @method string getSnapshotId()
* @method void setSnapshotId(string $v)
* @method string getKind()
* @method void setKind(string $v)
* @method string|null getLabel()
* @method void setLabel(?string $v)
* @method int getCreatedAt()
* @method void setCreatedAt(int $v)
* @method int|null getFiles()
* @method void setFiles(?int $v)
* @method int|null getBytes()
* @method void setBytes(?int $v)
*/
class Snapshot extends Entity {
protected int $targetId = 0;
protected string $snapshotId = '';
protected string $kind = '';
protected ?string $label = null;
protected int $createdAt = 0;
protected ?int $files = null;
protected ?int $bytes = null;
public function __construct() {
$this->addType('targetId', 'integer');
$this->addType('createdAt', 'integer');
$this->addType('files', 'integer');
$this->addType('bytes', 'integer');
}
}