On this page

8.5 Hardened repositories

A hardened repository protects backups on a Linux server against deletion and encryption by malware: every written file is made immutable for a configurable number of days, so even the server itself can no longer delete it. This is worthwhile for the most important local repository when no Object Lock capable cloud is available.

How it works

After a data, index, snapshot, key or config file is written, the helper service pdc-immutable-helper sets the file system attribute "immutable" (chattr +i). A file marked this way cannot be deleted, renamed or changed, not even by root, as long as the attribute is set. Only the helper can remove it again after the lock has ended.

The helper is a separate service with root privileges on the repository host. The server (which runs as the user pdc-backup without special privileges) asks it over a Unix socket for locks and releases. The helper keeps its own records of expiry times and limits and releases files only after their lock has ended. A compromised server process therefore cannot delete backups early. The helper never shortens the days.

Requirement

Note

Linux server

Hardening exists only for local repositories on a Linux server.

File system

ext4 (tested), XFS or btrfs (not tested) on a local disk. Network drives, SMB, SFTP, WebDAV and S3 are excluded.

No Object Lock

A repository is either S3 with Object Lock or locally hardened.

Clock

The helper decides on expiry by the system clock. The clock must be synchronized at boot.

Retention

Every job that writes into the repository needs a time-based retention longer than the lock (see section 8.4 Retention).

Setup

  1. Start the helper. The Linux packages (.deb and .rpm) contain the helper service pdc-immutable-helper and the unit pdc-immutable-helper.service, but do not start it on their own. It is paired later in the repository panel with Set up helper… (step 4). First enable and start the unit:

sudo systemctl enable --now pdc-immutable-helper
  1. Wait for the clock at boot. The unit starts after time-sync.target; that target alone does not wait for NTP. Enable the wait service of your time daemon:

# systemd-timesyncd
sudo systemctl enable systemd-time-wait-sync.service
# chrony
sudo systemctl enable chrony-wait.service
  1. Create or edit the repository. In the editor, for a Local disk, tick Make every written file immutable for under Hardened (immutable files, Linux server) and enter the days (whole number from 1 to 36500, default 30). Save. If the retention of existing jobs does not fit, the editor refuses to save and names the jobs.

  2. Pair the helper. In the repository details choose Set up helper…. The interface shows a command with a single-use token, valid for 60 minutes, labeled Enroll command:

echo <token> | sudo pdc-immutable-helper enroll --root <repository folder> --token-file -

Run the command as root on the repository host. It registers the folder with the helper and lists it in a systemd drop-in (pdc-immutable-helper.service.d/50-repository-roots.conf) so the helper may write there (--no-systemd skips the systemd part).

  1. Complete pairing: click it. The message "Helper paired; N file(s) locked" confirms that existing files were locked.

Until pairing is complete, writes to the repository fail. If the token expires or the command was mistyped, New setup token… creates a fresh one.

Options in the editor

Option

Effect

Default

Make every written file immutable for

Turns hardening on for this repository.

off

Hardened lock days (number field after the tick)

Lock period of every written file in days, 1 to 36500. The helper clamps the value to its own range.

30

The hints below the field say: the helper needs a local ext4, XFS or btrfs disk; after saving, pair it in the repository panel; even the server cannot delete or change a locked file; config and keys stay locked; every writing job needs a time-based retention above the lock.

Helper configuration

The helper reads /etc/pdc-immutable-helper/config.toml. The file must belong to root and be writable only by root; the server cannot change any of it. If the file is missing, the defaults apply.

/etc/pdc-immutable-helper/config.toml
NameRequiredDefaultDescription
socket/run/pdc-immutable-helper/helper.sockUnix socket the server uses to talk to the helper (mode 0660, group of the server user). Must match hardened_helper_socket in server.toml.
state_dir/var/lib/pdc-immutable-helperDirectory with lock records and enrolled repository folders, root only. It is kept when the package is removed; otherwise locked files would stay immutable for good.
server_userpdc-backupAccount the PDC-Backup server runs as (name or numeric UID). Only this account may talk to the helper; the helper checks this through SO_PEERCRED.
min_days7Shortest lock in days (fractions allowed). Shorter requests from the server are raised to this value.
max_days3650Longest lock in days, at most 36500. Longer requests are cut to this value. 0 <= min_days <= max_days <= 36500 must hold.

The server's socket path is set in server.toml under hardened_helper_socket (default as above). The other keys are listed in chapter 13 Configuration Reference.

The Hardened section of a repository

In the repository details, Hardened shows the state of the helper:

Display

Meaning

checking the helper…

The server is querying the helper.

helper unreachable / error

The socket is missing, the helper is not running or does not answer. Writes fail in that case.

not paired

"writes fail until the helper on this host is paired". See pairing above.

immutable, "N d"

The repository is hardened, with the configured lock period in days. If the helper's period differs, "(helper: N d)" is shown.

"The helper allows N to M days"

The range min_days to max_days of the helper configuration.

N locked ("N permanent")

Number of currently locked files; config and the key files stay locked permanently.

next expiry

When the earliest lock ends.

N hidden

Index and key files that prune replaced but that are still locked (see below).

"N lock request(s) failed since the server started"

The next maintenance locks what is left.

"N file(s) expired, released by the next maintenance"

Expired locks are released during maintenance.

The right-click menu offers Copy repository root, Copy helper ID, Copy helper socket, Copy oldest expiry and Copy enroll command. Besides Set up helper… and Complete pairing, the section shows "enrolled on the host, waiting until …" after the command was run on the host.

Retention, prune and forget

Retention, prune and forget behave as with S3 Object Lock (see section 8.3 Storage types):

  • Locked packs and snapshot files stay; forget skips locked snapshots and reports them as "immutable (hardened repository)".

  • Locked index and key files that prune replaces are hidden and removed only after release. The list is kept in the file .pdc-hardened-hidden in the repository root; the restic command line does not read it.

  • Prune leaves packs alone that are younger than the lock period plus one day.

  • The maintenance job first asks the helper to release expired files and locks again files whose lock request failed. The run log shows the numbers ("hardened repository: N file(s) released by the helper …").

  • config and the key files stay locked until an administrator of the host releases them.

Security model

Protection against

Effect

Malware on an agent

Agents write only through the server; they cannot reach the storage directly.

Malware or a bug in the server

Even the server process cannot delete or change locked files or shorten the lock.

Stolen server account pdc-backup

The helper accepts requests from this account only, limits the days to its own range and never releases files before expiry.

Tampered clock

If the wall clock jumps ahead of the boot clock by more than an hour, the helper pauses releasing.

root on the repository host

No protection. Whoever has root on the host can stop the helper, manipulate the file system directly or remove the disk.

The unit confines the helper to the capabilities CAP_LINUX_IMMUTABLE, CAP_FOWNER, CAP_DAC_READ_SEARCH and CAP_CHOWN, with no network and a read-only file system except its state directory and the enrolled repository folders.

Testing on a test repository

Before production use, verify on a test repository that the lock holds:

lsattr -R /srv/test-repo | head
sudo rm /srv/test-repo/config     # must fail with "Operation not permitted"

The helper decides on expiry by the system clock, so do not change the clock during the test. The records under /var/lib/pdc-immutable-helper survive removal of the package because otherwise locked files would stay immutable for good.

Last updated Nov 16, 2026