How to add a usb storage to proxmox and backup pve config and VMs all via command line?

dan8888

New Member
May 19, 2023
6
0
1
So, I have lost access to the proxmox web gui on one of my nodes because it is failing to boot up properly. I can however, type in commands via command line as I have a monitor and keyboard physically connected to the machine.

Is it possible for me to add a usb storage device to proxmox via command line such that I could then backup the VMs and other useful config data (all via command line)? If so, how?

This was a massive 'dough!!' moment as this proxmox node had all my VMs on the boot drive just whilst I was in the process of setting up high availability with 2 other nodes. Really frustrating, but I'm hoping there's a solution to make this a less painful mistake.

Thanks in advance
 
You can copy the /etc folder as well as the config.db, as your /etc/pve with most of PVEs configs will be empty.
For the virtual disks of your VMs it depends on what storage was used.
 
the vrtual disks are located on the boot drive with ZFS file system. i can list the virtual machine disks with
Code:
zfs list
however there is no mount point. what are my options?

Knowing that the easiest option to backup the VM would be using the built-in pve commands (vzdump i think), i looked into what is causing the pve cluster service to fail - as that may be the easier route out of this. From looking at the logs, it looks like the error is '/etc/pve/local/pve-ssl.key: failed to load local private key (key_file or key) at usr/share/perl5/PVE/APIServer/AnyEvent.pm line 1996'. Based on other forum threads, i've checked my hosts file and all seems expected. So not exactly sure where to look next.
 
the vrtual disks are located on the boot drive with ZFS file system. i can list the virtual machine disks with
Code:
zfs list
however there is no mount point. what are my options?

Knowing that the easiest option to backup the VM would be using the built-in pve commands (vzdump i think), i looked into what is causing the pve cluster service to fail - as that may be the easier route out of this. From looking at the logs, it looks like the error is '/etc/pve/local/pve-ssl.key: failed to load local private key (key_file or key) at usr/share/perl5/PVE/APIServer/AnyEvent.pm line 1996'. Based on other forum threads, i've checked my hosts file and all seems expected. So not exactly sure where to look next.
ZFS isn't using files for VMs. It is using zvols which are block devices, so you won't find a file you can copy. To backup a zvol you could either use "zfs send" and pipe that to a file or backup that zvol on block level with for example "dd".
 
thanks for the info. Using what you said, i've managed to get the VM hard disks off the old drive and onto a new host. I used the data in the config.db to create the new VMs.

The old drive is a Seagate NVME and failed within 2 months which isn't great but perhaps it wasn't designed to be used in server with ZFS. I'm starting to think that it failed because of the additional read/writes that the ZFS file system puts on the disk. Because of the limited benefit of a single disk ZFS file system provides, i've opted to go for ext4 on the new host. At some point i'll go back to ZFS when i setup dual boot drives.
 
Because of the limited benefit of a single disk ZFS file system provides, i've opted to go for ext4 on the new host. At some point i'll go back to ZFS when i setup dual boot drives.
You still get features like bit rot detection (but not protection), block level compression, quotas, snapshots, encryption, replication, deduplication, ... with a single disk pool.
But yeah, best would be to use ZFS with a mirror of enterprise grade SSDs. Then it doesn't really matter if a disk fails within the 5 years warranty and it hopefully doesn't wear that fast.
 

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!