Skip to content

Instantly share code, notes, and snippets.

@wyanez
Created July 24, 2012 05:36
Show Gist options
  • Save wyanez/3168238 to your computer and use it in GitHub Desktop.
Save wyanez/3168238 to your computer and use it in GitHub Desktop.
[bash] Script para respaldo de las VM con VirtualBox
#!/bin/sh
# Script para respaldo de las VM con VirtualBox
# William Yanez - 07/2012
VM_RUNNING=$(VBoxManage list runningvms | wc -l)
if [ $VM_RUNNING -gt 0 ]; then
echo "Error: Hay $VM_RUNNING VM's Activas"
VBoxManage list runningvms
exit
fi
DIR_BACKUP=/VMs/VirtualBox_VMs/backup/
# Guardo El Separador de tokens, por defecto ' '
OLD_IFS=$IFS
# Obtengo la lista de VMs en el sistema y las voy respaldando una a una
VBoxManage list vms | awk '{print $1}' FS="{" | awk '{print $2}' FS="\"" | while IFS=\n read VM
do
VM_BAK=$(echo $VM | tr -d ' ')
echo Respaldando: "$VM en $VM_BAK.ova"
VBoxManage export "$VM" --output $DIR_BACKUP/$VM_BAK.ova
done
IFS=$OLD_IFS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment