On this page

5.1 How an agent works

The agent (pdc-agent) is the program that runs on every machine you back up. It opens an encrypted connection to the server on its own, carries out the server's orders, and reports progress and results. This page explains startup, the connection, and the path of a job from the server to the finished snapshot.

Service and startup

The agent runs as a background service with the highest rights on the machine, because it has to read every file (reasons in section 5.7 Permissions and service accounts).

Property

Windows

Linux

Service

PDCBackupAgent (display name "PDC-Backup Agent")

systemd unit pdc-agent.service

Account

LocalSystem

root

Program

C:\Program Files\PDC-Backup Agent\pdc-agent.exe

/opt/pdc-agent/pdc-agent

State folder

C:\ProgramData\PDC-Backup\agent

/var/lib/pdc-agent

Start

Service, calls pdc-agent.exe service run --state-dir <folder>

ExecStart=/opt/pdc-agent/pdc-agent run

The Linux unit starts the agent after network-online.target, restarts it 10 seconds after a crash (Restart=always, RestartSec=10), and runs it at low priority (Nice=10, IOSchedulingClass=idle). RuntimeDirectory=pdc-agent creates the folder for the local socket /run/pdc-agent/agent.sock (see section 5.6 Tray app and self-service). On Windows the service manager handles start and stop.

You can change the state folder with --state-dir <folder> or the environment variable PDC_AGENT_DIR. What lives there is described in section 5.2 Enrollment and identity.

pdc-agent commands

Command

Effect

enroll --server <URL> --token <token> [--force]

Registers the machine with the server using a one-time token. --force replaces an existing enrollment. The token can also come from PDC_ENROLL_TOKEN.

install --server <URL> --token <token>

Windows only, as administrator: copies the program to Program Files\PDC-Backup Agent, enrolls the machine, registers and starts the service.

run

Runs in the foreground (this is how systemd starts the agent; also useful for testing).

service install / service uninstall

Windows only: registers or removes the PDCBackupAgent service.

status [--json]

Shows connection, protection status, and jobs. If the service is not reachable, it shows the last saved state.

snapshots, browse, restore, backup-now

Self-service for local users (section 5.6 Tray app and self-service).

recovery [--config <file>] [--non-interactive]

Restore console of the recovery medium (chapter 09 Restore).

The commands update-helper and uninstall-helper are hidden; the agent starts them itself during an update or uninstall.

Connection to the server

The agent always connects to the server, never the other way around (port 8444). No port has to be opened on the backed-up machine; only the outbound connection to the server must be allowed.

  • Encryption: TLS with mutual certificates. The agent presents its certificate from the server's own CA and accepts only a server whose certificate comes from that CA and whose key it has pinned (server.pins). Details in chapter 11 Users and Security.

  • One session: A single long-lived stream carries orders, cancel commands, progress, log lines, results, and heartbeats. Connecting takes at most 15 seconds; HTTP/2 keep-alive runs every 30 seconds.

  • Start of the session: The agent tells the server its version, host name, operating system and architecture, the run IDs of jobs that are still running or just finished, the workloads it supports, a status report (disks, detected applications), the SHA-256 checksum of its program, the platform, the run mode (systemd, windows-service, or process), and its capabilities (for example mounting restore points, which needs FUSE or WinFsp).

  • Reply from the server: The server names the heartbeat interval (server setting heartbeat_secs, default 15 seconds, allowed 5 to 300), its current key pins, and the key that agent packages are signed with. Only then does the agent accept orders.

  • Heartbeat and status: The agent sends a sign of life at the heartbeat interval. Every 15 minutes it refreshes free disk space and detected workloads; Refresh status in the web interface forces this immediately.

  • Progress: While a job runs, the agent reports progress at most once per second and only when something changed, but at least every 15 seconds.

Reconnecting

Situation

Behavior

Connection drops or the server is unreachable

Retry after 1 s, then double the wait each time up to 60 s, plus up to 1 s of random offset so that many agents do not return at the same moment. A session that was up before resets the wait to 1 s.

The server refuses the agent (revoked or certificate replaced)

The agent reports "rejected", writes a note to its log, and tries again every 5 minutes. For a fix see section 5.2 Enrollment and identity (re-enrollment).

Certificate expires soon

Before every session the agent checks its certificate. When less than a third of its validity is left (the last 10 days of a 30-day certificate), it fetches a new one. While jobs are running it waits, unless the certificate expires in less than one day.

Jobs without a connection

A running job does not depend on the session. If the connection drops, the job keeps working and its events wait in a queue (at most 5000; on overflow the oldest log lines are dropped, never a result). Finished jobs stay stored for 10 minutes and are sent again in every new session; the server ignores duplicates. Because the agent reports run IDs on reconnecting, the server does not wrongly mark a run as failed. A run counts as lost only when the agent has been away longer than offline_run_timeout_minutes (default 15; chapter 13 Configuration Reference).

When the service stops, the agent cancels all running jobs.

How a job arrives and runs

The server sends every order to the agent over the session. It contains the run ID, the kind (backup, restore, and others, see below), the workload, the job's settings, repository access, options, pre and post scripts, and stored credentials.

  1. Accept: The agent remembers every run ID. An order delivered twice is ignored.

  2. Start: The job starts independently of other jobs; several jobs can run in parallel. The server limits how many may start at once (max_jobs_per_agent, max_jobs_per_repository).

  3. Apply options: The upload limit (KiB/s), "low priority", and "sleep after job" apply to exactly this run. For workloads with a backup type (full, differential) the agent writes the choice to the log, for example "backup type: differential". If there is no full backup yet, a differential run reads everything ("full").

  4. Open the repository: The agent reaches the repository through the server's REST endpoint (same port 8444, https://<server>:8444/<path>). It never holds storage credentials. The password of its own repository key arrives with the order and stays in memory for this job only. The agent may only append, not delete or overwrite. A local cache (encrypted index and snapshot files) lives in <state folder>/cache; it is switched off for repositories with a per-machine index.

  5. Pre script, backup, post script: For backup jobs with scripts, the pre script runs first, then the actual backup, then the post script (section "Scripts before and after the backup").

  6. Report: During the run, progress (bytes, files, current file, phase) and log lines go to the server and appear live in the web interface. At the end comes the result with success or error, the snapshot ID, and the summary including the number of warnings and the phase timeline.

  7. Clean up: If "sleep after job" was chosen, the agent checks whether the machine may go to sleep now (section "Power and offline machines").

Kinds of orders

Kind

What the agent does

backup

Backs up the job's workload (files, disk image, database, Docker, VM) into the repository.

restore

Restores data from a snapshot (see below).

scan

Pre-check of a backup, for example the virus scan of a restore (chapter 09 Restore).

verify

Restore test: restores samples or databases into a test area and compares them.

mount

Mounts a restore point read-only (Linux with FUSE, Windows with WinFsp).

instant

Instant recovery.

agent-update

Updates the agent itself (section "Self-update").

agent-uninstall

Removes the agent from the machine (section "Uninstall by the server").

Update and uninstall need neither a repository nor a workload. If the server requests a workload this agent does not know, the run ends with a message that the agent does not support that workload; the agent reported its supported workloads when it connected.

Scripts before and after the backup

Backup jobs can have a pre and a post script (setup in chapter 06 Jobs; only administrators can change them). The agent writes the script text to a file under <state folder>/tmp and runs it with the agent's account (LocalSystem or root); the file is deleted afterwards.

Property

Behavior

Interpreter

Windows: PowerShell (-NoLogo -NoProfile -NonInteractive -ExecutionPolicy Bypass) or cmd; Linux: sh or bash. With "auto" the agent uses PowerShell or sh.

Working folder

<state folder>/tmp

Output

Every stdout line goes into the run log as info, every stderr line as a warning.

Time limit

Default 300 seconds, at most 86,400; after that the script and its child processes are killed.

On error

"fail" or "warn" per script. A failed pre script set to "fail" skips the backup. With "warn" the backup continues and the run gets a warning.

Post script

Always runs once the pre script was attempted, also after a failed or cancelled backup (it typically undoes what the pre script did). A cancel does not stop it. If it fails with "fail", the run counts as failed, but the snapshot is kept.

Environment variables in both scripts:

Variable

Content

PDC_PHASE

pre or post

PDC_JOB_ID, PDC_JOB_NAME

ID and name of the job

PDC_RUN_ID

ID of the run

PDC_RUN_KIND

always backup

PDC_WORKLOAD

workload of the job, for example files

PDC_AGENT_ID, PDC_HOSTNAME

ID and host name of the agent

PDC_REPOSITORY_ID

ID of the target repository

PDC_STATUS

post script only: success, warning, failed, or cancelled

PDC_SNAPSHOT_ID

post script only: ID of the new snapshot, empty on failure

PDC_ERROR

post script only: error text, empty on success

# Post script (PowerShell): send a ping only on success
if ($env:PDC_STATUS -eq 'success') {
    Invoke-WebRequest -UseBasicParsing "https://monitor.example/ping?job=$($env:PDC_JOB_NAME)&snap=$($env:PDC_SNAPSHOT_ID)" | Out-Null
} else {
    Write-Output "Backup $($env:PDC_JOB_NAME): $($env:PDC_STATUS) $($env:PDC_ERROR)"
}

Restore on the agent

A restore arrives as an order of kind restore with the snapshot's workload and the settings from the restore dialog (target, conflict handling, selection). The agent reads the data from the repository through the server's REST endpoint and writes it to the machine with its own rights (LocalSystem or root), so owners, permissions, and on Windows security descriptors and alternate data streams can be restored. File restores, databases, VMs, and images differ only in the workload part; the options are in chapter 09 Restore. Restore by local users with their own identity is a separate path (section 5.6 Tray app and self-service).

Self-update

The server distributes agent packages; an update is a job of kind agent-update. Section 5.5 Managing multiple agents describes how to trigger it. This is what happens on the machine:

  1. The order describes the package: platform, version, SHA-256, size, Ed25519 signature, and download path. If the running program is already identical, the run ends at once with "already_current".

  2. The agent checks the signature against the package key it pinned at enrollment. A package signed with a different key is refused. It installs an older version only if an administrator explicitly asked for it (allow_downgrade).

  3. It downloads the package through the agent endpoint (mutual TLS) and checks size and SHA-256.

  4. It starts the update helper, a copy of the new program. If this copy does not report within 15 seconds, the agent uses its own program as the helper.

  5. The helper stops the service (systemd, Windows service, or, for a hand-started agent, the process), keeps the old program as <program>.old, puts the new one in place, and starts it.

  6. The new agent connects and reports the run as successful.

  7. If no confirmation arrives within 90 seconds (adjustable in the order), the helper restores the old program and starts it. The old agent reports the update run as failed in its next session.

The update appears in Runs as its own run. It needs no additional rights because the helper runs with the agent's rights.

Uninstall by the server

Uninstall in the web interface sends an agent-uninstall order (option: also delete state, see section 5.3 Agent list and details). The agent copies itself to a temporary folder, starts a helper from there, and reports the order as done. The helper waits 5 seconds so the result reaches the server (which then revokes the agent), stops the agent, removes the service registration and the program, and optionally the state folder. If the agent is offline, the uninstall runs as soon as it connects again. Backups in the repositories stay.

Power and offline machines

Topic

Behavior

During a job

On Windows the agent prevents standby while a job runs. On Linux it does not keep the machine awake during a job.

Low priority

With the agent setting (section 5.4 Agent settings) the agent lowers CPU and I/O priority for the job: on Linux nice 19 and I/O class "idle" for the worker thread, on Windows the thread's background mode.

Sleep after job

Only after a scheduled backup with the setting enabled. The agent waits up to 2 minutes for the result to reach the server, then one more minute. It suspends the machine only if no other job is running, no user is logged in, and nothing is left unsent. Otherwise the machine stays on (noted in the agent log).

Machine off or asleep

A run for an offline agent waits in the state "pending_agent" and starts as soon as the agent connects, inside the allowed time window. With Wake-on-LAN (section 5.4 Agent settings) the server wakes the machine when a run is waiting for it. Catch-up and time windows are in chapter 07 Schedules and Plans.

Offline for long

If an agent stays offline longer than agent_offline_hours (default 48), the server raises the alert "agent_offline" (chapter 10 Monitoring and Reports).

Last updated Nov 16, 2026