Playbook: backups and restore
Nội dung này hiện chưa có sẵn bằng ngôn ngữ của bạn.
Backups run on the box as archives (.tar.gz plus a manifest) that are pushed to a
destination. They use dedicated operations, not jobs_create. That’s because a
backup carries sealed destination credentials that the API injects itself.
Token: operate to create and run jobs. Restoring needs full + backups:restore
with no server allowlist, since restore is a fleet-wide operation. Deletes need
data:delete. Plan: local destinations on every plan; object storage (S3, R2, B2,
rclone/Google Drive) from Plus (below it: 403 tier_limit). Server-to-server (peer)
destinations are Pro+ and need the holder server online on agent 0.2.143 or newer: create with kind: "peer", config.peer_server_id = the
holder; the API provisions an SFTP account on the holder in the same call. If the holder is
older or offline you get 502 peer_provision_failed (400 unsupported_kind on an older
control plane): do not retry, ask the user to update the holder’s agent (agent_update) or
offer an object destination. The holder cannot back up to its own peer (use local). All
sources share one account on a holder, so any of them can read or delete the others’
archives: suggest mode: "advanced" when the servers belong to different people, and tell
the user to download each source server’s backup key (it lives only on that server). Each plan also caps the number of destinations and backup
jobs.
1. Pick or add a destination
Section titled “1. Pick or add a destination”backup_destinations_listlists destinations without their credentials. Alocaldestination needs no credentials.- Adding one:
backup_destinations_create {body: {kind: "local"|"object", label, provider?, config, cred_sealed?}}(full+webhooks:admin). Object-storage credentials must be sealed client-side to the servers’ public keys (backups_recipients). An agent should usually ask the user to add credentialed destinations in the dashboard (/backups) and then pick the new destination from the list. - MZPanel Cloud Backup (storage MZPanel provides,
backup-100gbadd-on, $3 / 100 GB, every plan):backups_cloudreturnsenabled,state(active|grace= add-on removed, read-only untilgraceUntil, then deleted),quotaBytes,usedBytes,destinationId(put it indestination_ids) andkeyNotSaved(servers whose encryption key was never downloaded — tell the user: without the key those backups cannot be restored). Turning it on needs the owner in the dashboard (Backups → Destinations); a token cannot. A full space makes runs fail with “Cloud Backup is full” until the user adds storage or lowers retention. - Check it from a server:
backup_destinations_test {id, body: {server_id}}(records the status) orbackup_destinations_check {id, body: {server_id}}.
2. Create a scheduled job
Section titled “2. Create a scheduled job”backup_jobs_create {id: <server UUID>, body}:
{ "name": "nightly-sites", "kind": "full", "target_kind": "site", "targets": [{ "target_kind": "site", "name": "shop.example.com" }, { "target_kind": "stack", "name": "shop" }], "schedule": { "freq": "daily", "time": { "h": 2, "m": 30 }, "tz": "UTC" }, "destination_ids": ["<destination uuid>"], "retention": { "keep": 14, "unit": "days" }, "encrypt": false, "enabled": true}kind:full,databaseorfiles.target_kind:site,app,stackorserver.schedule.freq:hourly,daily,weekly,monthlyorcustom. Optional fields:everyHours,weekdays(0–6),monthdays(1–31),time {h, m},cronandtz.retention:{keep: 1–3650, unit: "days" | "copies"}.encrypt: trueseals each archive with a per-server passphrase. The user must keep that passphrase, and a token cannot read it.include_image: true(app targets): each app archive also carries the app image, so an app built on its server from git or an upload restores on another server. Archives grow by the image size; a server without the free disk fails the run withimage_no_space. Suggest it for apps built from source.
Edit with backup_jobs_update, and pause or resume with backup_jobs_toggle.
3. Run now
Section titled “3. Run now”- A saved job:
backup_jobs_run {id: <server UUID>, jobId}answers{ok, started}. If the server is offline, the answer carrieserror.message: "Server is offline". Cancel withbackup_jobs_cancel {id, jobId}. - One site, Docker app or stack, without a saved job:
backups_run_once {id, body: {targetKind: "site"|"app"|"stack", target: <domain or name>, destinationId?, kind?}}.kind(fulldefault,files,database) applies to sites only;includeImage: true(apps only, else 400) saves the app image into the archive. It defaults to the local destination and returns the snapshot id and, when the server is not busy with another backup, a job stream; confirm the result withbackup_snapshots_list. A domain that is not a site on that server answers404 not_found.
Watch progress with backup_jobs_list {id} (last run status) and jobs_list {id}.
4. Snapshots
Section titled “4. Snapshots”backup_snapshots_list(addquery: {server_id}to filter) lists what can be restored.backup_snapshots_refresh {id}re-imports the catalog from the server’s destinations.backup_snapshots_verify {id}checks that completed snapshots still exist where they were stored.- Clean-up (
data:delete):backup_snapshots_delete {id}andbackup_snapshots_clear_failed.
5. Restore (confirm with the human first)
Section titled “5. Restore (confirm with the human first)”backup_snapshots_restore {id: <snapshot id>, body} needs full + backups:restore:
{ "scope": "full", "target_server_id": "<optional other server>", "target_site": "<optional other domain>" }scopeis required:full,databaseorfiles.- The operation is fleet-wide (the snapshot’s server comes from its stored row, not
from the request), so a token with a server allowlist gets
403 fleet_wide. Use a token without an allowlist, even when you restore onto the same server. - With no target, the restore overwrites the original site, app or stack in place.
Pass
target_server_idand/ortarget_siteto restore a copy somewhere else. - A site restore stages the files, shows a 503 “being restored” page, dumps the
current database, imports, then swaps the files in; any failure rolls both back.
On failure read
failure.codeinjobs_get:restore_snapshot_failedandrestore_rolled_backmean the site runs as before (fix the cause, retry once);restore_rollback_failedmeans stop and tell the owner (the kept safety copies are named injobs_output). Docker app/stack restores have no rollback. - A Docker app built from source restores on another server only from a snapshot
whose
imageis set inbackup_snapshots_list(taken withinclude_image); the image is loaded there first. Without it the job failsimage_missingbefore touching anything: back the app up withincludeImage: trueon its own server first. - The answer is
{job_id, status, stream_url, target_server_id}. Polljobs_get {id: job_id}. If the target server is offline, you get409.
Before restoring in place, take a fresh backup of the current state (step 3), so the restore can itself be undone.
Verify
Section titled “Verify”After a run, backup_snapshots_list should show a new completed snapshot with a
non-trivial size. After a restore, re-read the site, app or database and fetch the URL.
Related
Section titled “Related”- Backups: what each option does in the dashboard.
- Safe operating rules