Created
July 24, 2012 05:36
-
-
Save wyanez/3168238 to your computer and use it in GitHub Desktop.
[bash] Script para respaldo de las VM con VirtualBox
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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