File-Level and Interactive Restore via CLI

unholyhumorousunratedoat

Well-Known Member
Sep 18, 2019
46
10
48
29
Hi guys,
I would like to restore on a file-level via CLI. In my scenario, the PVE and PBS are installed on the same physical machine. I'm running Proxmox Virtual Environment 8.2.4 and the Backup Server 3.2-6.

1727283205828.png

The Manpage for interactive restores looks good. I would like to use it to restore a folder on "drive-scsi1" from VM 102 via the CLI, not the Web GUI. Using the Web GUI works.

1727284777123.png

Code:
root@pve:~# proxmox-backup-client list | grep -A 1 -B 1 vm/102
+--------+-----------------------------+--------------+------------------------------------------------------------------------------------------------------+
| vm/102 | vm/102/2024-09-25T09:01:27Z |          260 | client.log drive-scsi0.img drive-scsi1.img index.json qemu-server.conf                               |
+--------+-----------------------------+--------------+------------------------------------------------------------------------------------------------------+

Code:
root@pve:~# proxmox-backup-client snapshot list vm/102 | grep -A 1 -B 1 vm/102/2024-09-24T
+-----------------------------+-----------+------------------------------------------------------------------------+
| vm/102/2024-09-24T09:02:00Z | 2.473 TiB | client.log drive-scsi0.img drive-scsi1.img index.json qemu-server.conf |
+-----------------------------+-----------+------------------------------------------------------------------------+

First weird thing is, that I can't use the `proxmox-backup-client catalog dump` command as you explained in the manual here.

Code:
root@pve:~# proxmox-backup-client catalog dump /vm/102/2024-09-24T09:02:00Z
Error: unable to parse backup snapshot path '/vm/102/2024-09-24T09:02:00Z'
root@pve:~# proxmox-backup-client catalog dump pbs-datastore/vm/102/2024-09-24T09:02:00Z
Error: unable to parse backup snapshot path 'pbs-datastore/vm/102/2024-09-24T09:02:00Z'
root@pve:~# proxmox-backup-client catalog dump /mnt/storage/pbs-datastore/vm/102/2024-09-24T09:02:00Z
Error: unable to parse backup snapshot path '/mnt/storage/pbs-datastore/vm/102/2024-09-24T09:02:00Z'

Alright, I'll just do the interactive restore. But this is where the problems begins. My backups are in .fidx format.

Code:
root@pve:~# proxmox-file-restore list vm/102/2024-09-24T09:02:00Z /
+======+======================+===============+===============+
| type | name                 | last modified |          size |
+======+======================+===============+===============+
| v    | drive-scsi0.img.fidx |               |   34359738368 |
+------+----------------------+---------------+---------------+
| v    | drive-scsi1.img.fidx |               | 2684354560000 |
+======+======================+===============+===============+

Code:
root@pve:~# proxmox-backup-client catalog shell vm/102/2024-09-24T09:02:00Z drive-scsi1.img.fidx
Error: Can only mount pxar archives.

Mounting also does not work.

Code:
root@pve:~# proxmox-backup-client mount vm/102/2024-09-24T09:02:00Z drive-scsi1.img.fidx restoremount
Error: Can only mount/map pxar archives and drive images.

Why is that? Can I change the (default) file format of my backups? Or did I do something wrong? Why is `proxmox-backup-client catalog dump` not working?

Thank you in advance :)
 
Last edited:
your backup contains virtual machine disk images, not a regular file backup. You want to use the "map" function to map the virtual disk image to a mountable device and examine the contents of the filesytems within the virtual disks.

The functions you want to use are for regular file backups.

Bash:
proxmox-backup-client map <snapshot> <archive-name> [OPTIONS]


Map a drive image from a VM backup to a local loopback device. Use 'unmap' to undo. WARNING: Only do this with trusted backups!

this will map the disk image from the backup as loopback device which you can then either examine using regular fdisk commands or use libguestfs tools to inspect and find/mount the filesystems contained within.
 
Last edited:
Thank you for your answer!

Unfortunately, it still doesn't work.

Code:
root@pve:/etc/proxmox-backup# proxmox-backup-client map vm/102/2024-09-24T09:02:00Z /drive-scsi1.img.fidx
Error: Can only mount/map pxar archives and drive images.

It still asks for pxar archives, but I have the fidx file. Do you have another idea?

Code:
root@pve:/etc/proxmox-backup# proxmox-file-restore list vm/102/2024-09-24T09:02:00Z /
+======+======================+===============+===============+
| type | name                 | last modified |          size |
+======+======================+===============+===============+
| v    | drive-scsi0.img.fidx |               |   34359738368 |
+------+----------------------+---------------+---------------+
| v    | drive-scsi1.img.fidx |               | 2684354560000 |
+======+======================+===============+===============+
root@pve:/etc/proxmox-backup# proxmox-file-restore list vm/102/2024-09-24T09:02:00Z /drive-scsi1.img.fidx
+======+=======+===============+======+
| type | name  | last modified | size |
+======+=======+===============+======+
| v    | part  |               |      |
+------+-------+---------------+------+
| v    | zpool |               |      |
+======+=======+===============+======+
root@pve:/etc/proxmox-backup# proxmox-file-restore list vm/102/2024-09-24T09:02:00Z /drive-scsi1.img.fidx/zpool
+======+========+===============+===============+
| type | name   | last modified |          size |
+======+========+===============+===============+
| d    | ncdata |               | 2680059592704 |
+======+========+===============+===============+
 
root@pve:/etc/proxmox-backup# proxmox-backup-client map vm/102/2024-09-24T09:02:00Z /drive-scsi1.img.fidx Error: Can only mount/map pxar archives and drive images.
Hi,
the proxmox-backup-client map command requires you to pass the drives archive name without the fixed index filename extension .fidx. Try proxmox-backup-client map vm/102/2024-09-24T09:02:00Z drive-scsi1.img.

That will map the image to a loop device, which you can then mount via the mount <path-to-loop-device> <mountpoint> command.
 
Thanks for your answer! I had to do it as root, sudo didn't work:

Code:
pveadmin@pve:~$ proxmox-backup-client map vm/102/2024-09-24T09:02:00Z drive-scsi1.img
storing login ticket failed: $XDG_RUNTIME_DIR must be set
Error: Permission denied (os error 13)

root@pve:~# proxmox-backup-client map vm/102/2024-09-24T09:02:00Z drive-scsi1.img
Image 'pbs-datastore:vm/102/2024-09-24T09:02:00Z/drive-scsi1.img' mapped on /dev/loop0

Mounting first didn't work, because I had to select the correct partition:

Code:
root@pve:/mnt# mount /dev/loop0 /mnt/restoremount/
mount: /mnt/restoremount: wrong fs type, bad option, bad superblock on /dev/loop0, missing codepage or helper program, or other error.
       dmesg(1) may have more information after failed mount system call.

Code:
root@pve:/mnt# lsblk
NAME                 MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINTS
loop0                  7:0    0   2.4T  1 loop
|-loop0p1            259:4    0   2.4T  1 part
`-loop0p9            259:5    0     8M  1 part

Then there was another error:
Code:
root@pve:/mnt# mount /dev/loop0p1 /mnt/restoremount/
mount: /mnt/restoremount: unknown filesystem type 'zfs_member'.
       dmesg(1) may have more information after failed mount system call.

As you can see from my previous post, the backup is a backup of my nextcloud VM where. In there, the data directory is using ZFS.

Code:
uadmin@nc:~$ zpool list
root@nc:~# zfs list
NAME     USED  AVAIL     REFER  MOUNTPOINT
ncdata  2.04T   328G     1.46T  /mnt/ncdata
root@nc:~# zpool list
NAME     SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT
ncdata  2.44T  2.04T   405G        -         -     2%    83%  1.00x    ONLINE  -

As proxmox-file-restore list vm/102/2024-09-24T09:02:00Z /drive-scsi1.img.fidx/ shows that zpool is a volume (I guess that's what the v stands for, I guess I should "map" this zpool from the disk image, right? Because in there is the actual directory `ncdata`.

Code:
root@pve:/mnt# proxmox-file-restore list vm/102/2024-09-24T09:02:00Z /drive-scsi1.img.fidx/
+======+=======+===============+======+
| type | name  | last modified | size |
+======+=======+===============+======+
| v    | part  |               |      |
+------+-------+---------------+------+
| v    | zpool |               |      |
+======+=======+===============+======+
root@pve:/mnt# proxmox-file-restore list vm/102/2024-09-24T09:02:00Z /drive-scsi1.img.fidx/zpool
+======+========+===============+===============+
| type | name   | last modified |          size |
+======+========+===============+===============+
| d    | ncdata |               | 2680059592704 |
+======+========+===============+===============+

But this doesn't work:
Code:
root@pve:/mnt# proxmox-backup-client map vm/102/2024-09-24T09:02:00Z drive-scsi1.img/zpool
Error: Can only mount/map pxar archives and drive images.

With the help of ChatGPT I got the thing clear:

Code:
Since you are working with a disk image (drive-scsi1.img) from a Proxmox Backup Server, which has been mapped using the proxmox-backup-client, the issue you are facing is that the partition (/dev/loop0p1) seems to contain a ZFS file system (zfs_member), which cannot be directly mounted using the mount command.

Code:
root@pve:/mnt# zpool import ncdata
cannot import 'ncdata': pool was previously in use from another system.
Last accessed by nc.jsyy.de (hostid=a73cf4a) at Tue Sep 24 11:00:07 2024
The pool can be imported, use 'zpool import -f' to import the pool.
root@pve:/mnt# zpool import ncdata -f
cannot import 'ncdata': permission denied
        Destroy and re-create the pool from
        a backup source.

After some more research, zpool import -f -o readonly=on -R /mnt/restoremount ncdata did the trick.
Code:
root@pve:/mnt# zpool list
NAME     SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT
ncdata  2.44T      0  2.44T        -         -     0%     0%  1.00x    ONLINE  -

It shows the files!
Code:
root@pve:/mnt/restoremount/mnt/ncdata# zfs list
NAME     USED  AVAIL  REFER  MOUNTPOINT
ncdata  2.04T   330G  1.51T  /mnt/restoremount/mnt/ncdata

Code:
root@pve:/mnt/restoremount/mnt/ncdata# ls -l
total 20
drwxr-xr-x 14 www-data www-data 14 Apr 30 21:35 hidden
drwxr-xr-x  2 www-data www-data  3 Jun 29 20:03 hidden
-rw-rw-r--  1 www-data www-data  0 Sep 14 20:02 hidden
drwxr-xr-x  7 www-data www-data  7 Jan  3  2024 hidden
drwxr-xr-x  5 www-data www-data  5 Jan  7  2024 hidden
drwxr-xr-x  5 www-data www-data  5 Aug  1 06:24 hidden
drwxr-xr-x  5 www-data www-data  5 Jan  3  2024 hidden
drwxr-xr-x  5 www-data www-data  5 Jan  6  2024 hidden

Then exporting the pool:
Code:
root@pve:/mnt/ncdata# zpool status
  pool: ncdata
 state: ONLINE
status: Some supported and requested features are not enabled on the pool.
        The pool can still be used, but some features are unavailable.
action: Enable all features using 'zpool upgrade'. Once this is done,
        the pool may no longer be accessible by software that does not support
        the features. See zpool-features(7) for details.
  scan: scrub repaired 0B in 02:35:59 with 0 errors on Sun Sep  8 05:00:01 2024
config:

        NAME        STATE     READ WRITE CKSUM
        ncdata      ONLINE       0     0     0
          loop0     ONLINE       0     0     0

errors: No known data errors

root@pve:/mnt/ncdata# zpool export ncdata
root@pve:/mnt/ncdata# zpool status
no pools available

And unmapping the backup:
Code:
root@pve:/# proxmox-backup-client unmap /dev/loop0

I'm very happy :) Thank you!!!
 
Last edited:
  • Like
Reactions: Chris
Dear @Chris,

I have the problem when I use proxmox-backup-client list or proxmox-file-restore list vm/142/2024-10-03T01:23:15Z / I get always the error massage: Error: unable to get (default) repository

What is wrong?

Best Tim
 
Last edited:
Hi, you forgot to set the shell variable (maybe you did it but changed to root e.g.) or you didn't specify the repository.

So you can do either
Code:
proxmox-backup-client list --repository pbs-datastore

Or
Code:
export PBS_REPOSITORY='pbs-datastore'
proxmox-backup-client list
 
I always do the following before working with the backup commands to keep the commands short. The second command removes the root password from history. :cool:

Code:
export PBS_PASSWORD='pbs_password'
builtin history -d $((HISTCMD-1))
export PBS_REPOSITORY='datastore_name'
export PBS_FINGERPRINT="fingerprint_of_your_repository"
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!