remote-backups.comremote-backups.com
Contact illustration
Sign In
Don't have an account ?Sign Up

PBS Change Detection Mode Metadata Explained

Your container backup ran for hours again, but only a few log files changed since yesterday. The reason is simple: in the default mode, the Proxmox Backup client reads every file on every run. This post explains how change detection mode "metadata" stops that, how it decides that a file is unchanged, and where it can miss a change.

Key Takeaways
  • File-level backups (containers and hosts) have three change detection modes: legacy (the default), data, and metadata.
  • Metadata mode compares file metadata with the previous snapshot and reuses the stored chunks of unchanged files. It does not read their content again.
  • Metadata mode compares mtime, size, file type, ownership, permissions, ACLs and attributes. It ignores ctime and the inode number.
  • A file that changes but keeps its size and mtime is not detected. Use data mode for a periodic full read.
  • The first metadata backup after a switch reads all files, because no split archive exists yet.
  • The modes came with Proxmox Backup Server 3.3. Use client 3.4 or later: it fixes a bug where file size was not compared.

The problem with the default mode

Proxmox Backup Server stores file-level backups as pxar archives. VM backups use a different path (fixed-size chunks and, on a running VM, dirty bitmaps), so they are not part of this topic. Change detection modes apply to file-level backups: LXC containers and hosts that you back up with proxmox-backup-client.

In the default mode, legacy, the client reads all files and encodes them into one self-contained pxar archive. The client splits that stream into variable-sized chunks and calculates a digest for each chunk. When the server already has a chunk, the client does not upload it again. This is why deduplication works well, as we explain in Proxmox Fast Incremental Backups Explained.

But deduplication only saves the upload. The client still reads every byte on the disk to find out which chunks are new. On a large and mostly static dataset, for example a file server container with years of documents, the read is the slow part. The official client docs give this as the reason for the new modes: file-based backups with a lot of data can take a long time, because the default mode reads all data again.

Deduplication is not change detection

Deduplication prevents a second upload of the same chunk. Change detection prevents a second read of the same file. Metadata mode adds the second step on top of the first.

The three modes

The --change-detection-mode option of proxmox-backup-client and the pbs-change-detection-mode option of vzdump accept three values:

  • legacy: the client reads and encodes all files into one pxar archive (pxar format version 1). This is the current default.
  • data: the client reads and encodes all files, but it writes two archives: one for metadata and one for file content (pxar format version 2). It does not reuse anything from earlier snapshots.
  • metadata: the client writes the same split archive as data mode. It also uses the metadata archive of the previous snapshot to find unchanged files and reuses their chunks without a new read.

The split archive: mpxar and ppxar

In data and metadata mode, a snapshot has two archive files:

  • The mpxar archive holds the metadata: file names, directory tree, ownership, permissions, timestamps, and the position of each file's content.
  • The ppxar archive holds the file payloads, one after the other.

This split is the base for metadata mode. The client can download the small metadata archive of the last snapshot, compare it with the live file system, and then refer to existing payload chunks for each file that did not change. The server also uses the mpxar archive to list archive contents and to browse files, for example in a single-file restore.

How metadata mode decides that a file is unchanged

At the start of a run, the client downloads the mpxar archive of the previous snapshot as a reference. For each file, it compares the current metadata with the stored entry. According to the Proxmox Backup Server technical overview, the comparison includes:

  • file size
  • file type
  • ownership and permissions
  • ACLs and attributes
  • the modification time (mtime), which the docs call the most important value

The client does not compare ctime or the inode number. These values change every time a tool copies files to a temporary location before the backup, which vzdump can do for containers. If the client compared them, it would detect almost every file as changed.

How the client reuses chunks

When a file is unchanged, the client does not read it. It looks up the chunk digests for that file's payload range in the index of the previous ppxar archive and puts these chunks into the new snapshot again.

There is one complication. A chunk can contain the end of one file and the start of the next file. If the client reuses such a chunk for one file, the other part of the chunk is "padding": data that the new snapshot does not need. To keep this waste small, the client puts unchanged files into a look-ahead cache. It stops the cache when the cache is full, when it finds a changed file, or when the payload range is not continuous. Then it checks the padding:

  • If the padding is 10% or less of the reused chunk content, the client reuses the chunks.
  • If it is more, the client encodes all cached files again, as if they were new.

The client also gives file boundaries to the chunker as suggested chunk boundaries. The chunker can accept or ignore them. Over time, this helps to align chunks with files, so that more chunks can be reused cleanly.

Where metadata mode can miss a change

Metadata mode trusts the metadata. If a file's content changes but its size and mtime stay the same, the client does not see the change. It reuses the old chunks, and the snapshot holds the old content.

This is rare, but it can happen. Examples are tools that restore the original mtime after a write, or a file that you edit and then reset with touch -d. The official docs name this limit and give the solution: data mode reads all content again and does not miss such changes.

Plan a periodic full read

If your workload can change files without a new mtime, schedule a second backup job in data mode, for example once a week. It reads every file again and gives you a snapshot that does not depend on metadata.

Use a current client

The Proxmox Backup Server 3.4 release notes list a fix for metadata mode: in earlier versions, file size was not part of the comparison, and this could cause later restores to fail. Before you use metadata mode, update proxmox-backup-client on your hosts and update your Proxmox VE nodes to current packages.

How to turn it on

For a host backup with proxmox-backup-client

Add the option to the backup command. The example backs up the root file system of a host. Use your own repository string and archive name.

bash
export PBS_REPOSITORY='backup@pbs@pbs.example.com:datastore1'
proxmox-backup-client backup root.pxar:/ \
    --change-detection-mode=metadata
Host backup in metadata mode

Keep the archive name the same from run to run. The client looks for the previous snapshot of the same backup group and the same archive to find its reference. A complete setup with a systemd timer is in Proxmox VE Host Backup and Node Rebuild.

For containers with vzdump

For one container, set the option on the command line:

bash
vzdump 123 --storage pbs-storage --pbs-change-detection-mode metadata
Container backup in metadata mode

For scheduled backup jobs, Proxmox VE 8.3 and later show the setting in the Advanced tab of the backup job. You can also set a node-wide fallback in /etc/vzdump.conf:

bash
pbs-change-detection-mode: metadata
/etc/vzdump.conf

The setting applies only to container backups to a Proxmox Backup Server storage. VM backups and backups to other storage types do not use it.

Server version

The change detection mode is a client-side setting, and the docs state that it is backwards compatible with older Proxmox Backup Server versions. To browse the new split archives in the web interface, the server must run version 3.2.5 or later.

What to expect after the switch

The first run reads everything. Metadata mode needs a split archive from a previous snapshot. After a switch from legacy mode, the last snapshot is a single pxar archive, so the first metadata run reads and encodes all files. The runs after that can reuse unchanged files.

Deduplication between old and new snapshots is lower. The docs state that pxar archives and split archives in the same datastore cannot be deduplicated as efficiently. The new format encodes content in a different layout, so the first split-archive snapshot writes many new chunks. Plan for some extra datastore space until your old legacy snapshots age out under your prune rules. The rules are explained in PBS Keep Rules Explained, and the space comes back after garbage collection, as described in Proxmox Backup Server Pruning and Garbage Collection.

Restore stays the same. You restore a split-archive snapshot with the same tools as before: the web interface, proxmox-backup-client restore, and the file restore tools. See PBS File-Level Restore: Recover Single Files for the steps. Test one restore after the switch, as with any change to your backup chain.

Common mistakes

  • Mixing modes in one job without a plan. Each switch between legacy and the split format causes a full read and lower deduplication. Choose a mode and keep it.
  • Only metadata mode, forever. Without a data mode run from time to time, a change that keeps size and mtime can stay out of your backups for a long time.
  • An old client. Clients before 3.4 did not compare file size in metadata mode. Update first.
  • New archive names. If you rename the archive (for example from root.pxar to rootfs.pxar), the client finds no reference and reads all files again.
  • Expecting faster VM backups. VM backups do not use pxar and do not use this setting.

Wrapping up

Metadata mode changes what the client reads. Instead of a full read on every run, it compares metadata with the previous snapshot and reads only files that changed. There are three costs: the client trusts mtime and size, the first run after the switch reads all files, and deduplication against old legacy snapshots is lower. Use a current client, add a periodic data mode run, and test a restore after the change.

Need an offsite target for your file-level backups?

remote-backups.com provides Proxmox Backup Server datastores in German data centers as an offsite target for your backups.

See the PBS offering

The data and metadata modes came with Proxmox Backup Server 3.3. Proxmox VE 8.3 added the setting to the Advanced tab of backup jobs. Version 3.4 fixed a bug where file size was not compared.

No. The setting applies only to file-level backups: containers and hosts backed up with proxmox-backup-client. VM backups use fixed-size chunks and dirty bitmaps.

Yes, if a file changes but keeps its size and mtime. Data mode reads all content again and does not miss such changes, so run it from time to time.

Yes. The client docs list legacy as the current default. You must set data or metadata mode explicitly per job, per command, or node-wide in /etc/vzdump.conf.

Metadata mode needs the metadata archive of a previous split-archive snapshot. After a switch from legacy mode, that archive does not exist yet, so the first run reads all files.
Bennet Gallein
Bennet Gallein

remote-backups.com operator

Infrastructure enthusiast and founder of remote-backups.com. I build and operate reliable backup infrastructure powered by Proxmox Backup Server, so you can focus on what matters most: your data staying safe.