NetPoa Cloud Backup Agent API v1 · draft

Server integration guide and agent API · updated 27 November 2026

Overview

To add a server, a team installs the NetPoa backup agent, points it at its Storage Box sub-account, and lists its Laravel apps in one .netpoa-backup.yml file. Nothing in the app's own code changes.

Three rules shape the design:

  1. The agent calls the panel, never the reverse. No inbound ports open on any app server.
  2. Backups do not depend on the panel. The agent keeps the schedule locally and keeps backing up if cloud.netpoa.com is down. It reports once the panel is back.
  3. Backup data never passes through the panel. It goes from the server to the Storage Box. The panel only reads snapshots (through a read-only sub-account) for browsing and downloads.

This is draft v1. The panel and agent are not built yet. This document is the contract both are built to, and the steps teams follow to add their servers.

Before you start

A server can be added when every line below holds.

Requirement Detail
OS Ubuntu 22.04 or 24.04, x86_64
Access root or passwordless sudo on the server
Outbound HTTPS to cloud.netpoa.com:443
Outbound SSH to <sub-account>.your-storagebox.de:23
Database tools mysqldump / mysql for MySQL or MariaDB; pg_dump / psql for PostgreSQL
Free disk 2 GB, or 10% of the biggest database, for temporary dumps and safety copies
Storage Box sub-account created in Hetzner Console with SSH on, Samba and WebDAV off, external reachability on
Panel entry the sub-account username saved in the admin UI (step 2 below)

Inbound ports do not change. The agent opens no listening port.

Adding a server

Seven steps, about 20 minutes per server. Steps 1–2 are done by a NetPoa admin; steps 3–7 by whoever runs the server.

  1. Create the sub-account (Hetzner Console → Storage Box → Sub-accounts → Create).

    1. Base directory: /<server-slug>, for example /changisha.
    2. SSH on, Samba off, WebDAV off, external reachability on, read-only off.
    3. Keep the generated password in the password manager. It is typed once, in step 4, and never sent to the panel.
  2. Register the server in the admin UI (cloud.netpoa.com → Servers → Add server).

    1. Enter the name, a slug, the sub-account username (u123456-sub1) and its base directory.
    2. The panel creates the restic repository password. Download the recovery sheet it offers and store it offline.
    3. Copy the one-time enrollment token. It is valid for 24 hours and works once.
  3. Install the agent on the server. Compare the checksum with the one the panel shows before running it.

    curl -fsSLo /tmp/netpoa-install.sh https://cloud.netpoa.com/agent/install.sh
    sha256sum /tmp/netpoa-install.sh
    sudo bash /tmp/netpoa-install.sh --token <ENROLLMENT_TOKEN>
    

    The installer adds a pinned restic version and the agent, creates /etc/netpoa-backup/ (root only), generates the Storage Box SSH key, and enrolls with the panel.

  4. Give the agent access to the Storage Box. This asks for the sub-account password once.

    sudo netpoa-backup storagebox install-key
    sudo netpoa-backup storagebox test
    
  5. Describe each app with a .netpoa-backup.yml in its root (next section), then register it:

    sudo netpoa-backup app add /var/www/changisha
    
  6. Run the first full backup. It creates the repository on the first run.

    sudo netpoa-backup run --policy weekly
    
  7. Prove a restore from the panel: one file to another folder, and the database into a new database. The server is live only once both pass.

Agent commands

Command Does
netpoa-backup status Agent, panel and Storage Box connection, last and next run per policy
netpoa-backup app add <path> Validates the manifest, reads the database settings, reports the app to the panel
netpoa-backup app list Apps on this server and what each backs up
netpoa-backup run --policy hourly|daily|weekly Runs a backup now, outside the schedule
netpoa-backup snapshots [--app <slug>] Lists restore points
netpoa-backup restore ... Command-line restore, same options as the panel
netpoa-backup logs [-f] Agent log

Laravel apps: the manifest

Each app describes what to back up in .netpoa-backup.yml at its root, committed to the app's repository. The agent reads it on app add and whenever it changes.

version: 1
app: changisha              # slug, unique on this server
type: laravel               # laravel | generic
user: www-data              # owner of restored files; runs the artisan hooks

databases:
  - from_env: .env          # DB_CONNECTION, DB_HOST, DB_PORT, DB_DATABASE, DB_USERNAME, DB_PASSWORD
  # - name: changisha_reports
  #   connection: mysql      # extra database on the same credentials

files:
  include:
    - .                     # the app folder, including .env and storage/app
  exclude:
    - vendor/
    - node_modules/
    - .git/
    - bootstrap/cache/
    - storage/logs/
    - storage/framework/cache/
    - storage/framework/sessions/
    - storage/framework/views/

config:                     # backed up by the weekly full only
  - /etc/nginx/sites-available/changisha
  - /etc/cron.d/changisha
  - /etc/php/8.3/fpm/pool.d/changisha.conf
  - /etc/supervisor/conf.d/changisha-worker.conf

hooks:
  before_restore:
    - php artisan down --retry=60
  after_restore:
    - php artisan optimize
    - php artisan queue:restart
    - php artisan up

Defaults for type: laravel

Database access

Apps that are not Laravel

Use type: generic and list each database with name, connection, host, port, username, and password_file (a root-only file holding the password). Hooks default to none.

Agent API v1

Base URL https://cloud.netpoa.com/api/agent/v1. JSON in and out, UTF-8, times in ISO 8601 UTC. The agent is the only client; teams never call this API by hand.

Authentication

Endpoints

Method & path Called Purpose
POST /enroll once, by the installer Trade the enrollment token for an agent id, agent token, Storage Box target and repository password
POST /heartbeat every 60 s Report health; learn if jobs or new config are waiting
GET /config when config_version changes Fetch schedules, retention and apps
POST /apps on app add and manifest change Report an app and its parsed manifest
POST /jobs/claim when the heartbeat says jobs wait Take the next job (manual backup, restore, verify, prune)
POST /jobs/{id}/progress every 5 s while a job runs Percent, bytes, current item
POST /jobs/{id}/log batched, every 5 s Log lines shown live in the panel
POST /jobs/{id}/complete once per job Final status and stats
POST /runs after each scheduled run Report a backup the agent started on its own schedule
POST /snapshots/sync after every backup and prune Current list of snapshots in the repository
POST /token/rotate when asked New agent token

POST /enroll

{
  "enrollment_token": "enr_7Kq...",
  "hostname": "changisha-vps",
  "os": "Ubuntu 24.04.1 LTS",
  "agent_version": "1.0.0",
  "restic_version": "0.17.3",
  "storagebox_public_key": "ssh-ed25519 AAAA... netpoa-backup@changisha-vps"
}

Response 201:

{
  "agent_id": "srv_01JD8X...",
  "agent_token": "agt_...",
  "storage": {
    "host": "u123456-sub1.your-storagebox.de",
    "port": 23,
    "user": "u123456-sub1",
    "repository": "sftp:u123456-sub1@u123456-sub1.your-storagebox.de:/restic"
  },
  "repository_password": "...",
  "config_version": 1
}

POST /heartbeat

{
  "agent_version": "1.0.0",
  "uptime_s": 86400,
  "disk_free_bytes": 18253611008,
  "storagebox_reachable": true,
  "running_job_id": null,
  "last_runs": { "hourly": "2026-11-27T07:00:41Z", "daily": "2026-11-26T23:06:12Z", "weekly": "2026-11-22T00:14:03Z" }
}

Response 200: { "jobs_waiting": 1, "config_version": 3, "rotate_token": false }.

GET /config

{
  "config_version": 3,
  "timezone": "Africa/Dar_es_Salaam",
  "policies": {
    "hourly": { "enabled": true, "cron": "0 * * * *",  "scope": ["databases"],                    "keep": 24 },
    "daily":  { "enabled": true, "cron": "0 2 * * *",  "scope": ["databases", "files"],           "keep": 14 },
    "weekly": { "enabled": true, "cron": "0 3 * * 0",  "scope": ["databases", "files", "config"], "keep": 8 }
  },
  "bandwidth_limit_kbps": null,
  "verify": { "cron": "0 4 * * 0", "read_data_subset": "5%" }
}

The agent writes these schedules into systemd timers, so backups keep running while the panel is unreachable.

POST /jobs/claim

Response 200 with one job, or 204 when nothing waits.

{
  "id": "job_01JD9...",
  "type": "restore",
  "requested_by": "jacob",
  "params": {
    "app": "my-netpoa",
    "snapshot": "4bf1c2e9",
    "items": [
      { "kind": "file", "path": "/var/www/my.netpoa.com/storage/app/invoices/INV-2026-0418.pdf" },
      { "kind": "dir",  "path": "/var/www/my.netpoa.com/storage/app/invoices/receipts" }
    ],
    "target": { "mode": "original", "overwrite": true, "safety_copy": true }
  }
}

Job types

type params Notes
backup app?, policy Manual run; same as a scheduled one
restore app, snapshot, items[], target Files and folders
restore_db app, snapshot, database, tables?[], target target.mode: original or new_database (+ name)
restore_full app, snapshot, confirm_code Files, all databases and config; runs the app's hooks
verify read_data_subset restic check; result shown as the weekly test
prune — Applies retention now

target.mode for files is original, alternate (+ path) or download. Downloads are served by the panel straight from the Storage Box, so the agent never sees them.

POST /jobs/{id}/complete and POST /runs

{
  "status": "success",
  "started_at": "2026-11-27T07:00:02Z",
  "finished_at": "2026-11-27T07:00:41Z",
  "snapshot": "9a7c0d11",
  "stats": { "files_new": 12, "files_changed": 40, "bytes_added": 41943040, "bytes_total": 3543348019 },
  "warnings": [],
  "error": null
}

status is success, warning or failed. POST /runs takes the same body plus policy.

Errors

Errors return { "error": { "code": "job_not_found", "message": "..." } }.

HTTP When Agent does
400 Body fails validation Logs it, does not retry
401 Token wrong, rotated or revoked Stops calling, logs, keeps local backups running
404 Unknown job or app Drops that job
409 Job already claimed or finished Drops that job
429 More than 120 calls a minute Waits for Retry-After
5xx / timeout Panel down Retries with backoff up to 10 min; reports are queued on disk and sent later

Snapshots, schedules and retention

Every server has one restic repository at /restic inside its sub-account. Each run makes one snapshot per item, tagged so the panel can group them.

Item Snapshot path Tags
App files the app folder, e.g. /var/www/changisha app:changisha kind:files policy:daily
Database /db/<database>.sql (MySQL) or /db/<database>.dump (PostgreSQL) app:changisha kind:db db:changisha policy:hourly
Server config the paths under config: app:changisha kind:config policy:weekly
Policy Runs (EAT) Backs up Keeps
Hourly every hour at :00 databases 24
Daily 02:00 databases + files 14
Weekly Sunday 03:00 databases + files + config 8

Restores

Every restore is a job started in the panel and run by the agent, except downloads, which the panel serves itself.

Restore What happens Site stays up
File or folder → original place Live copies are moved to .netpoa-restore/<timestamp>/ in the app folder (kept 7 days), then the snapshot copies are written with the app's owner Yes
File or folder → another folder Written under the chosen path; nothing live is touched Yes
Database → new database <name>_restored_<HHMM> is created and filled; the app keeps using the live one Yes
Database → original A safety dump of the live database is taken first, then the snapshot is loaded Yes, if the hooks are off; by default the app is put in maintenance mode
Single tables Only the chosen tables are dropped and loaded, after a safety dump of those tables Yes
Full server before_restore hooks, then files, every database and config, then composer install --no-dev, npm ci if a lockfile exists, then after_restore hooks No, maintenance mode throughout
Download The panel streams a .zip (files) or .sql.gz (database) through the read-only sub-account; the link lasts 24 hours Yes

Security

Done checklist and troubleshooting

A server counts as protected when every box is ticked.

Symptom Likely cause Fix
storagebox test fails: connection refused Outbound port 23 blocked, or SSH off on the sub-account Allow outbound 23; turn SSH on in Hetzner Console
storagebox test fails: permission denied Key not installed on that sub-account Run storagebox install-key again
app add cannot reach the database .env points at another host, or uses a socket the agent cannot see Set host and port explicitly in the manifest
Enrollment returns 401 Token used, or older than 24 hours Create a new token in the admin UI
Server shows Offline in the panel No heartbeat for 5 minutes systemctl status netpoa-backup; check outbound 443
Hourly run marked Slow Upload under 10 MB/s or run over 60 s Check the server's bandwidth; set bandwidth_limit_kbps if it hurts the site