[TUTORIAL] Examples on how to mount PBS backup images for file level restoring

entilza

Well-Known Member
Jan 6, 2021
180
38
48
49
Mounting PBS Backups for File level restore using Command Line Interface

Show latest backups:
# proxmox-backup-client list --repository root@pam@10.1.16.44:tank9

To show all backups/snapshots:
# proxmox-backup-client snapshot list --repository root@pam@10.1.16.44:tank9

To show all backups/snapshots for a specific vm: (ex: vm/200)

# proxmox-backup-client snapshot list vm/200 --repository root@pam@10.1.16.44:tank9
┌─────────────────────────────┬─────────┬────────────────────────────────────────────────────────────────────────┐ │ snapshot │ size │ files │ ╞═════════════════════════════╪═════════╪════════════════════════════════════════════════════════════════════════╡ │ vm/200/2023-07-28T21:16:59Z │ 214 GiB │ client.log drive-scsi0.img drive-scsi1.img index.json qemu-server.conf │ ├─────────────────────────────┼─────────┼────────────────────────────────────────────────────────────────────────┤ │ vm/200/2023-08-25T21:16:41Z │ 214 GiB │ client.log drive-scsi0.img drive-scsi1.img index.json qemu-server.conf │ ├─────────────────────────────┼─────────┼────────────────────────────────────────────────────────────────────────┤ │ vm/200/2023-09-29T21:16:43Z │ 214 GiB │ client.log drive-scsi0.img drive-scsi1.img index.json qemu-server.conf │ ├─────────────────────────────┼─────────┼────────────────────────────────────────────────────────────────────────┤ │ vm/200/2023-10-20T21:16:53Z │ 214 GiB │ client.log drive-scsi0.img drive-scsi1.img index.json qemu-server.conf │ ├─────────────────────────────┼─────────┼────────────────────────────────────────────────────────────────────────┤ │ vm/200/2023-10-23T22:01:36Z │ 214 GiB │ client.log drive-scsi0.img drive-scsi1.img index.json qemu-server.conf │ ├─────────────────────────────┼─────────┼────────────────────────────────────────────────────────────────────────┤ │ vm/200/2023-10-24T21:17:14Z │ 214 GiB │ client.log drive-scsi0.img drive-scsi1.img index.json qemu-server.conf │ ├─────────────────────────────┼─────────┼────────────────────────────────────────────────────────────────────────┤

Mount an image (.img)

# proxmox-backup-client map vm/200/2023-10-23T22:01:36Z drive-scsi1.img --repository root@pam@10.1.16.44:tank9
Image 'root@pam@10.1.16.44:8007:tank9:vm/200/2023-10-23T22:01:36Z/drive-scsi1.img' mapped on /dev/loop0

# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS loop0 7:0 0 150G 1 loop ├─loop0p1 259:0 0 16M 1 part └─loop0p2 259:1 0 150G 1 part

# mount /dev/loop0p2 /mnt/test/
mount: /mnt/test: WARNING: source write-protected, mounted read-only.

# cd /mnt/test
# ls -l
<< /mnt/test directory shows contents of drive-scsi1.img (partition 2 in this example)
# cd /
# umount /mnt/test
# proxmox-backup-client unmap /dev/loop0

Mounting / Restoring PVE files: (.pxar files)

# proxmox-backup-client snapshot list --repository root@pam@10.1.16.44:tank9 | grep host

│ host/pve-art/2023-10-30T10:25:01Z │ 2.787 MiB │ catalog.pcat1 index.json pve-etc.pxar │
│ host/pve-art/2023-10-31T10:25:01Z │ 2.787 MiB │ catalog.pcat1 index.json pve-etc.pxar

proxmox-backup-client mount host/pve-art/2023-10-30T10:25:01Z pve-etc.pxar /mnt/test/ --repository root@pam@10.1.16.44:tank9

FUSE library version: 3.10.3

# cd /mnt/test
# ls -l
<< /etc directory shows - copy whatever you need>>
# cd /
# umount /mnt/test
 
Last edited:
Interestingly, I'm trying this out with the PVE integration... When I'm trying to mount a snapshot of a VM on the PBS server to browse the backup, I'm getting:

Code:
root@pbs:/mnt# mount -o ro /dev/loop0p2 /mnt/tmp/
mount: /mnt/tmp: cannot mount /dev/loop0p2 read-only.
       dmesg(1) may have more information after failed mount system call.

Then in the dmesg output:
Code:
[74541.402550] XFS (loop0p2): Mounting V5 Filesystem 363c7c89-eacc-44fb-b285-3fec017672ba
[74541.404081] XFS (loop0p2): recovery required on read-only device.
[74541.404085] XFS (loop0p2): write access unavailable, cannot proceed.
[74541.404086] XFS (loop0p2): log mount/recovery failed: error -30
[74541.404281] XFS (loop0p2): log mount failed

As such, it doesn't seem to be possible to mount the backup.

Where to go from here?
 
Yeah - I mean, it makes sense that it would be read-only image - however if we can't mount it at all, then it means recovering an individual file via the PBS client isn't really possible.

I did note that the "File Restore" function in PVE seems to allow me to browse the image though:
1750558579042.png

This seems like there is *some* way to do this, but I'm not 100% sure how...

@t.lamprecht always seems to have an insight into stuff I can't figure out :D

Any ideas? :)
 
I retested my instructions and they all checked out..

I guess it depends on the filesystem that the VM guest is using. In this case, something about how the backup functions causes the mount to fail. The block device is still there and available, but the filesystem can't be mounted.
 
My linux VM was ext4 in above example, I wonder if the XFS is somehow damaged?

I have a feeling that its the way PVE has snapshotted / backed up the VM... ie when the filesystem is still in use.

It's obviously mostly in tact, as I can browse the files in PVE's "File Restore" - but likely because it isn't cleanly unmounted. XFS would normally check the fs on mounting next, but as it can't clear the 'unclean' flag, it refuses to mount.

I wonder how PVE's 'File Restore' accesses the image - as obviously it can access the contents of it...

EDIT: Of course it was something simple....

Code:
# mount -o ro,norecovery /dev/loop0p2 /mnt/tmp/

The norecovery mount option was all it needed...
 
Last edited:
  • Like
Reactions: entilza