Extracting data from *.vma file

Aug 19, 2019
57
7
13
Hi,
I have a de-compressed dump file (*.vma decompressed from *.lzo) with 250 GB and want to extract all contents of the /var/www directory selectively from the main drive of this VM (drive-scsi0). I can not find any documentation to handle this with the vma cli tool. So, what is the correct syntax here

vma extract vzdump-qemu-100-2020_05_17-01_30_02.vma

The documentation for "vma" is pretty limited and https://pve.proxmox.com/wiki/Backup_and_Restore#vzdump_restore has no info how to handle restoration on the command line ...

Thanks for some hints, Thommie
 
The vma comman is pretty simple:

# vma
usage: vma command [command options]

vma list <filename>
vma config <filename> [-c config]
vma create <filename> [-c config] pathname ...
vma extract <filename> [-r <fifo>] <targetdir>
vma verify <filename> [-v]

So you just need to specify the target directory:

# vma extract vzdump-qemu-100-2020_05_17-01_30_02.vma /your/target/dir

This extracts the VM disks as binary image files. You need to mount them if you want to access the files.
 
  • Like
Reactions: fireon
Bash:
#!/bin/bash
echo "vmaRecover 1.0"
if [ -z ${1} ] || [ -z ${2} ] || [ "$1" == "-h" ] ; then
   echo "vmaRecover.sh <file.vma.zst> </workingDir> [clean]"
   echo "Working dir contains subfolder with raw_image and loop folder for mounting file Systems."
   exit 0
fi

file=$1
workingDir=$(echo "$2" | sed 's:/*$::')
recSubDir=/raw_image

if [ "${3}" == "clean" ]; then
   echo "============================================================"
   echo "Cleanup"
   echo "============================================================"
   echo Unmounting loop-Devices
   umount ${workingDir}/loop*
   losetup -D
   echo remove ${workingDir}${recSubDir}
   rm -r ${workingDir}${recSubDir}
   echo remove ${workingDir}/loop*
   rm -r ${workingDir}/loop*
   exit 0
fi


if [ ! -f "$file" ]; then
    echo "Datei existiert nicht: $file"
    exit 1
fi

if [ -d "${workingDir}${recSubDir}" ]; then
    echo "Ordner darf nicht existieren: ${workingDir}${recSubDir}"
    exit 1
fi

echo "============================================================"
echo "Extracting $file to ${workingDir}${recSubDir}"
echo "============================================================"
mkdir -p ${workingDir}
zstd -q -d -c ${file} | vma extract -v - ${workingDir}${recSubDir}

echo "============================================================"
echo "Create Loop Devices"
echo "============================================================"
loop=$(shuf -i 10-50 -n1)
rawFile=$(find ${workingDir}${recSubDir} -name "*.raw")

losetup /dev/loop${loop} ${rawFile}
sleep 1
partx -v --add /dev/loop${loop}
readarray parts < <(ls -1 /dev/loop${loop}p*)

echo "============================================================"
echo "Mount Image"
echo "============================================================"
for part in "${parts[@]}"
do
   mkdir -p ${workingDir}/${part##*/}
   mount ${part} ${workingDir}/${part##*/}
   echo "Partition eingebunden: ${workingDir}/${part##*/}"
done

#"mount //192.168.178.254/Freigabe ${workingDir}/smb -o user=USER"

Does it for you...
Does not mount lvm container inside raw image.
Does not work properly if more than one disk per vma file
Must be adopted if image is no zstd.
 
Last edited:

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!