V. article We installed and configured the virtualization server using a free Virtualbox program with virtual machine management through the phpvirtualbox web interface.
Based on the fact that it is always necessary to have the latest current copy of the virtual machine, you can configure the archiving of both the contents of the virtual machine (or rather only the necessary data) and the image of the entire virtual machine. Of course, we can say that archiving the database and files of the site with some configuration files of working servers is much more practical - you can, for example, raise a second virtual machine on the internal interface next to it, configure replication of the master - sleeve, and already from it do archive the database at least every minute, and synchronize files through rsync to the dump as often as necessary. But to raise a virtual machine from the source files (bd, files, configs) is much longer than to connect a ready-made image from the archive in case there are problems with the main image of the hard drive of the virtual machine.
Therefore, I can recommend a simple script for archiving the main hard drive of the virtual machine. He is, of course, to perfection as to the sky by a certain way of transportation, but he works faultlessly.
It certainly has one big drawback: if you can’t let the virtual machine stop, it won’t work for you. Then you will have to configure archiving using Snapshots in Virtualbox. Principle of work: take a snapshot, transfer the work of the virtual machine from the hard drive to the snapshot, and at this time an archive of the hard drive is made, as soon as the archive is made, the virtual machine is transferred to work from the snapshot to the main screw of the virtual server and the snapshot is deleted - as a result of this option, all data that was changed during work on the snapshot will disappear, but the server will always be available.
Another thing I don’t recommend you to use when working with Virtualbox is Snapshot. That is, you install a server, configure the operating system, services, sites and make Snapshot, which allows you to roll back to this state at any time. This is good when you play with server setup, debugging. But as soon as you debug, remove the snapshot and work without it. If you do use it, the script will simply archive all data except those in Snapshot. We made an archive and in full confidence that all super sleep peacefully, but suddenly it turns out that the screw has died in the physical server, and you still need to recover from the archive yesterday, you just raise virtualbox c phpvirtualbox on a new hardware. articleYou fill in the archive, connect the screw to the virtual machine and see that you do not have any data - only an installed and configured server before creating Snapshot. Here you can save only the presence of archival copies of files and databases. Otherwise, it's fucked up.
You can also make an archive of a virtual machine using the bootable image of the Acronis True Image disk. Personally tried - working solution, ported so Server 2003. Transferred information and that to the snapshot and the contents of the snapshot.
The script of automatic archiving of the screw machine (do not kick hard for simplicity):
#!/bin/sh
# указываем переменную, которая добавит к имени дату, год, месяц и время создания файла
data="date +%Y%m%d-%H:%M`"
# сохраняем состояние виртуальной машины
/etc/init.d/virtualbox stop
# ждем 80 секунд пока машина сохранится
sleep 80
# запускаем архивацию винта: указываем файл винчестера виртуальной машины и
# куда его архивировать
# добавляя к имени переменную $data, что добавит к имени дату, год, месяц и
# время создания файла:
VBoxManage clonevdi /home/vbox/VirtualBox\ VMs/Jabber/Jabber.vdi /backup/Jabber_$data.vdi
#Запускаем виртуальную машину из сохраненного состояния
/etc/init.d/virtualbox start
# если необходимо, удаляем файлы в архиве, которым больше 5 дней
find /backup/ -mtime +5 -type f -exec rm -rf {} \;That's the whole simple script. It can be run as scheduled using crontabFor example, every week on a Saturday at 4-10 or manually when you need to.
I was with you. Sergey Lazarenko.




comment