Zum Hauptinhalt springen
Snapshots ersetzen die v3-backup- / backups-API. app.backup und app.backups werden in v4 weiterhin exportiert, geben aber eine Deprecation-Warnung aus und leiten an app.snapshots weiter. Aktualisiere deinen Code auf den neuen Namen.
app.snapshots stellt das SnapshotsModule bereit.
const app = await api.applications.fetch("abc123def456abc123def456");
app.snapshots; // SnapshotsModule

Snapshots auflisten

app.snapshots.list() liefert ein Array von Snapshot-Instanzen.
const snapshots = await app.snapshots.list();

for (const snap of snapshots) {
    console.log(snap.url);          // signierte Download-URL (30 Tage gültig)
    console.log(snap.size);         // Bytes
    console.log(snap.modifiedAt);   // Date
    console.log(snap.key);          // signierter Query-String
}
Jeder Snapshot kann direkt heruntergeladen werden:
const buffer = await snapshots[0].download();

Einen neuen Snapshot erstellen

app.snapshots.create() löst einen frischen Snapshot aus und liefert die signierte URL und den Key.
const fresh = await app.snapshots.create();
console.log(fresh.url); // 30 Tage gültig
console.log(fresh.key);

Download in einem Schritt

app.snapshots.download() erstellt einen Snapshot und lädt ihn als Buffer herunter.
import { writeFile } from "node:fs/promises";

const buffer = await app.snapshots.download();
await writeFile("./backup.zip", buffer);

Aus einem Snapshot wiederherstellen

app.snapshots.restore({ snapshotId, versionId }) setzt die Anwendung auf eine frühere Snapshot-Version zurück.
await app.snapshots.restore({
    snapshotId: "00000000-0000-4000-8000-000000000000",
    versionId: "abc123def4567890",
});
FeldTypBeschreibung
snapshotIdstringSnapshot-Bezeichner (UUID v4)
versionIdstringVon list() zurückgegebener Versionsbezeichner

Snapshots kontoweit auflisten

api.user.snapshots(scope) liefert jeden Snapshot, den du besitzt, über alle deine Anwendungen oder Datenbanken hinweg.
const appSnapshots = await api.user.snapshots("applications");
const dbSnapshots  = await api.user.snapshots("databases");
api.user.snapshots() erfordert ein aktives kostenpflichtiges Abonnement.