How to search for a file/folder from a LXC backup on PBS?

alpha754293

Member
Jan 8, 2023
150
22
23
I have well over 100 LXCs that I've backup over time.

I am trying to look for a specific folder now, and I was wondering, is there a way for me to search through all of the root.pxar.didx files somehow rather than manually clicking through each one via the PBS Datastore contents GUI?

Your help is greatly appreciated.

Thank you.
 
You could mount the backups with the backup Client and then use find to search for the files:
https://pbs.proxmox.com/docs/backup-client.html#mounting-of-archives-via-fuse
Another option would be to list the contents catalog and grep them: https://pbs.proxmox.com/docs/backup-client.html#restoring-data

It should be possible to script this
This would imply that if I have multiple namespaces, that I would have to "roll through" each of the backups, from each of the namespaces separately and dump out the catalog one by one, before I'd be able to grep them, correct?

And for my education, what would be the difference between the index.json that your second link refers to vs. the catalog?

What's written on the second link suggests that both would be a list of contents of the backup/snapshot, correct, and as far as I can tell, the difference being that the catalog I can pipe it (or redirect the output to a file using >) vs. dumping out the index.json file "directly".

Is that the only difference between the two?
 
Oh cool!

I will have to give that a shot.

From reading your readme.md though, it would appear that the search function would only work after you've created the SQLite table, correct?

*edit*
When I tried to read my .chunks/ directory, it says:

scan error: open /mnt/pve/dump/.chunks: permission denied

when I check the permissions, this is what it shows:

Code:
root@debian-pbs:/mnt/pve/dump# ls -la
total 1108
drwxrwxrwx 6 backup backup    4096 Mar 29 13:47 .
drwxr-xr-x 3 backup backup    4096 Sep 28  2024 ..
drwxr-x--- 1 backup backup 1056768 Sep 28  2024 .chunks
drwxr-xr-x 2 backup backup    4096 Sep 29  2024 ct
-rw-r--r-- 1 backup backup     331 Mar 29 07:28 .gc-status
-rw-r--r-- 1 backup backup       0 Sep 28  2024 .lock
drwxr-xr-x 7 backup backup    4096 Nov  6 21:14 ns
-rw-r--r-- 1 root   root     49152 Mar 29 13:47 pcat.db
drwxr-xr-x 2 backup backup    4096 Sep 29  2024 vm

How do you get around this permissions issue?
 
Last edited:
It should be possible to script this
I'll probably need the help of AI to script this because it dumps the name of the snapshot into a nice table, but I will need AI to write the script to be able to read said "pretty" table so that it knows that the first column is the snapshot name and then loop through each of those to write out the catalog file for each snapshot, in each of the namespaces that I've got.

Fortunately, it looks like reading said catalog is pretty quick, so it should be able to loop through all of my snapshots and namespaces pretty quickly.
 
Oh cool!

I will have to give that a shot.

From reading your readme.md though, it would appear that the search function would only work after you've created the SQLite table, correct?

*edit*
When I tried to read my .chunks/ directory, it says:

scan error: open /mnt/pve/dump/.chunks: permission denied

when I check the permissions, this is what it shows:

Code:
root@debian-pbs:/mnt/pve/dump# ls -la
total 1108
drwxrwxrwx 6 backup backup    4096 Mar 29 13:47 .
drwxr-xr-x 3 backup backup    4096 Sep 28  2024 ..
drwxr-x--- 1 backup backup 1056768 Sep 28  2024 .chunks
drwxr-xr-x 2 backup backup    4096 Sep 29  2024 ct
-rw-r--r-- 1 backup backup     331 Mar 29 07:28 .gc-status
-rw-r--r-- 1 backup backup       0 Sep 28  2024 .lock
drwxr-xr-x 7 backup backup    4096 Nov  6 21:14 ns
-rw-r--r-- 1 root   root     49152 Mar 29 13:47 pcat.db
drwxr-xr-x 2 backup backup    4096 Sep 29  2024 vm

How do you get around this permissions issue?

maybe apparmor blocking access?, try executing as backup user.
DB will be created by utility.
 
Last edited:
maybe apparmor blocking access?, try executing as backup user.
DB will be created by utility.
So I am on my PBS system itself (I installed PBS to a Debian VM, so apparmor shouldn't be an issue) and this is what I get when I tried to su backup:

Code:
root@debian-pbs:~# su backup
This account is currently not available.
 
Last edited:
To close this out, this is the script that I had codestral:22b write at first, and then I had to finish it off with the llama3.3:70b model.

Code:
#!/bin/bash
#
# This bash shell script file will dump out the catalog/list of files from a Proxmox VE backup/snapshot. Works with Proxmox Backup
# Server but I suppose it can be modified to work without Proxmox Backup Server as well. I used this to look for a specific 
# file/folder from _all_ of my backups and it's faster than clicking through the Proxmox Backup content/datastore/namespace 
# via the PBS GUI.
#
# Usage syntax: ./snapshot_catalog.sh
#
# Written by codestral:22b and then llama3.3:70b LLMs written on 2026-03-29.
#
# This works well with LXCs. It will _not_ dump out the contents from a VM. (To be fair, the PBS GUI doesn't let you look for files
# inside a VM backup neither.
#
# Before you begin, make sure that you export PBS_REPOSITORY system variable. Read the latest PBS documentation on how to do that.
# You might want to manually list the snapshots first so that you can log in to your PBS.

namespace="$namespace"  # Replace this with your namespace if different
output=$(proxmox-backup-client snapshot list --ns "$namespace")
# Extract snapshot names from the command output using regex
snapshots=($(echo "$output" | grep -oP '(?:ct|vm)/\d+/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z'))
# Print the list of snapshots and write out the catalogs to text files
echo "List of snapshots:"
for snapshot in "${snapshots[@]}"; do
    echo "$snapshot"
    # Execute the catalog dump command and write out the catalog of files to a file with the filename syntax $namespace_$snapshot_catalog.txt, replacing / with _
    proxmox-backup-client catalog dump --ns "$namespace" "$snapshot" &> "${namespace}_${snapshot//\//_}_catalog.txt"
    if [ $? -ne 0 ]; then
        echo "Error occurred while running command for snapshot $snapshot"
    fi
done

I just saved that as snapshot_catalog.sh, gave it execute permissions and it was able to read and dump out the catalogs for LXCs very well.

And then I just used grep to try to find what I was originally looking for.

(Sidenote: I was able to run the proxmox-backup-client from one of my PVE nodes where the PBS storage is defined. This helped me get around the permissions issue.)