The script looks like this:
Code: Select all
#!/bin/sh
VBoxManage controlvm WebServer2 savestate&&
VBoxManage controlvm Mailserver savestate&&
rm /media/LaCie/Server-Backup/WebServer2-5.vdi&&
mv /media/LaCie/Server-Backup/WebServer2-4.vdi /media/LaCie/Server-Backup/WebServer2-5.vdi&&
mv /media/LaCie/Server-Backup/WebServer2-3.vdi /media/LaCie/Server-Backup/WebServer2-4.vdi&&
mv /media/LaCie/Server-Backup/WebServer2-2.vdi /media/LaCie/Server-Backup/WebServer2-3.vdi&&
mv /media/LaCie/Server-Backup/WebServer2-1.vdi /media/LaCie/Server-Backup/WebServer2-2.vdi&&
rm /media/LaCie/Server-Backup/mailserver-5.vdi&&
mv /media/LaCie/Server-Backup/mailserver-4.vdi /media/LaCie/Server-Backup/mailserver-5.vdi&&
mv /media/LaCie/Server-Backup/mailserver-3.vdi /media/LaCie/Server-Backup/mailserver-4.vdi&&
mv /media/LaCie/Server-Backup/mailserver-2.vdi /media/LaCie/Server-Backup/mailserver-3.vdi&&
mv /media/LaCie/Server-Backup/mailserver-1.vdi /media/LaCie/Server-Backup/mailserver-2.vdi&&
VBoxManage clonehd /home/thomas/.VirtualBox/VDI/WebServer2.vdi /media/LaCie/Server-Backup/WebServer2-1.vdi&&
VBoxManage clonehd /home/thomas/.VirtualBox/VDI/mailserver.vdi /media/LaCie/Server-Backup/mailserver-1.vdi&&
VBoxManage startvm WebServer2 -type vrdp&&
VBoxManage startvm WebServer2 -type vrdp&&
I know its nothing fancy, and there should have been some if's to catch errors but im not good at scripts yet.
When running the script manually it works fine and doing what its supposed to but when running it as a crontab job it fails.
I have added it to Cron like this:
Code: Select all
sudo crontab -eCode: Select all
# m h dom mon dow command
0 1 * * * (/usr/bin/aptitude -y update && /usr/bin/aptitude -y safe-upgrade) 2$
0 2 * * * bash /home/thomas/Scripts/backup.sh 2>&1 >> /var/log/auto_backup.log
VirtualBox Command Line Management Interface Version 2.1.4
(C) 2005-2009 Sun Microsystems, Inc.
All rights reserved.
WARNING! The following VirtualBox settings files have been automatically
converted to the new settings file format version '1.6-linux':
/root/.VirtualBox/VirtualBox.xml (1.3-linux)
The current command was aborted to prevent overwriting the above settings
files with the results of the auto-conversion without your permission.
Please put one of the following command line switches to the beginning of
the VBoxManage command line and repeat the command:
-convertSettings - to save all auto-converted files (it will not
be possible to use these settings files with an
older version of VirtualBox in the future);
-convertSettingsBackup - to create backup copies of the settings files in
the old format before saving them in the new format;
-convertSettingsIgnore - to not save the auto-converted settings files.
Note that if you use -convertSettingsIgnore, the auto-converted settings files
will be implicitly saved in the new format anyway once you change a setting or
start a virtual machine, but NO backup copies will be created in this case.
I find this strange since it works when running the script manually.
Anyone who has an idea on a solution for this?