暂停、备份然后重新启动 virtualbox vm

暂停、备份然后重新启动 virtualbox vm

我希望能够暂停 Virtualbox 虚拟机,备份它,然后重新启动它。我想创建一个 cron 脚本来执行此操作。

我相信这些是我需要的命令,但我不知道如何备份(中间部分):

VBoxManage controlvm "Windows Server" savestate
while [ `VBoxManage list runningvms | grep "Windows Server" | wc -l` = "1" ]
do
    sleep 2
done

#here is the bit I don't know to do... 
#I need to somehow create a backup of the vm here... I'm sure its not
#that difficult, but I don't know where to start or whether what I
#would come up with would be the best way

#restart using start-stop-daemon... dunno why! This is in my init.d script
#and was the only way it worked (as far as I could work it! haha)
start-stop-daemon --background --chuid user --make-pidfile --pidfile "$PIDFILE" --start --exec /usr/bin/VBoxHeadless -- --startvm "Windows Server"

如果有人能给我几行代码,将我的虚拟机备份到特定位置,那就太好了。老实说,我在第一个障碍上失败了,然后我将尝试将备份打包并 rsync 到我的 NAS。之后我们会看到这部分有多容易!:p 哈哈

谢谢你们的帮助。

相关内容