ERROR: code NS_ERROR_INVALID_ARG (0x80070057) Deleting Snap Shot
All,
I am using Oracle VirtualBox 3.2.8. We have started moving away from VMWare and started using VirtualBox. I am having issues sometimes with the deletion and creation of snapshots using the VBoxManage command. I have a script the runs via cron each day:
+#!/bin/bash+
+# BackupVBox.sh - Backup Virtual Box Virtual Machines+
+# Written by Jesse Becker, OIT+
+#+
+# Use: ./BackupVBox.sh <day_of_week> (ie. ./BackupVBox.sh Mon)+
+#Set Variables+
VMBackupPath="/media/backups/VirtualServers/VirSer02/"
VMBackupLogPath="/media/backuplogs/Backup Logs/"
VMBackupFileName="$(date %Y)_$(date +%m)_$(date +%d)_$HOSTNAME.log"+
+VBoxMachinePath="/var/vbox/Machines"+
+VBoxHardDiskPath="/var/vbox/HardDisks"+
+VMListFile="/home/oitadmin/VMs"+
+#Remove Local Log File+
+rm -f logfile.txt+
+# Start Time Post in Log+
+echo "$(date) Backup Started" &> logfile.txt+
+echo "====================================================================" &>> logfile.txt+
+echo "Backup of virtual machines on $HOSTNAME has started..." &>> logfile.txt+
+echo " " &>> logfile.txt+
+echo "The following VMs are running on $Hostname:" | &>> logfile.txt+
+echo " " &>> logfile.txt+
+echo " " &>> logfile.txt+
+# List current Virtual Machines running on this host+
+VBoxManage list runningvms &>> logfile.txt+
+# Create snapshots+
+while read line+
+do+
+echo "Removing old snapshot Nightly from machine $line" &>> logfile.txt+
+echo "====================================================================" &>> logfile.txt+
+VBoxManage snapshot $line delete Nightly &>> logfile.txt+
+echo "Creating snapshot Nightly for machine: $line" &>> logfile.txt+
+echo "====================================================================" &>> logfile.txt+
+VBoxManage snapshot $line take Nightly &>> logfile.txt+
+done < $VMListFile+
+echo " " &>> logfile.txt+
+echo " " &>> logfile.txt+
+while read line+
+do+
+echo "Deleting $VMBackupPath$1$line.tar.gz" &>> logfile.txt+
+echo "====================================================================" &>> logfile.txt+
+rm -fR $VMBackupPath$1$line.tar.gz &>> logfile.txt+
+echo "Backing up $line to tar.gz file" &>> logfile.txt+
+echo "====================================================================" &>> logfile.txt+
+tar -cvzf $VMBackupPath$1$line.tar.gz $VBoxMachinePath/$line/* $VBoxHardDiskPath/$line* &>> logfile.txt+
+done < $VMListFile+
+echo "Deleting $VMBackupPath$1VBoxConfig.tar.gz" &>> logfile.txt+
+echo "====================================================================" &>> logfile.txt+
+rm -fR $VMBackupPath$1VBoxConfig.tar.gz &>> logfile.txt+
+echo "Backing up VirtualBox Configuration to tar.gz file" &>> logfile.txt+
+echo "====================================================================" &>> logfile.txt+
+tar -cvzf $VMBackupPath$1VBoxConfig.tar.gz ~/.VirtualBox &>> logfile.txt+
+echo " " &>> logfile.txt+
+echo "Done." &>> logfile.txt+
+# Post End Time to Log file+
+echo "$(date) Backup Ended" &>> logfile.txt+
+# Copy Log File+
+cp logfile.txt "$VMBackupLogPath$VMBackupFileName"+
+# End+
The script above runs every day. It is suppose to delete the existing Nightly snapshot (merging the differencing disks back together) and then create a new snapshot call Nightly. It then tar's the Hard Drive and Machine files to remote store (backup). The purpose for the snapshot is to correct any corruption that may occur as the hard disk may change while the taring happens.
Sometimes I get an error ERROR: code NS_ERROR_INVALID_ARG (0x80070057) with either the deleting or creation of the snapshot. This then puts me in a bind as I have a corrupt difference disk that I cannot delete nor can I replace. This then requires editing of XML files to remove the snapshot and in most cases losing changes that happened between snapshots.
Can anyone help me out with this one? Is there a better back strategy?
Thanks,
Jes