virtualbox question

For complex topics that regular users would not be interested in. For power users and database administrators.
Post Reply
murmsk
Posts: 177
Joined: Mon Jun 18, 2007 11:14 am
Location: Monmouth IL

virtualbox question

Post by murmsk » Thu Feb 28, 2013 8:46 am

I am rebuilding my server and am considering a virtual windows machine running under linux.

Question, Can the virtual machine be backed up without shutting it down ?

steve
steve

User avatar
jsalmon
Posts: 1551
Joined: Tue Nov 30, 2010 12:33 pm
Contact:

Re: virtualbox question

Post by jsalmon » Thu Feb 28, 2013 10:08 am

I was always under the impression that virtual machines should be treated like physical machines. So my personal answer would be no. However I was helping a gentleman the other day and he kept saying "If this doesn't work, I have a snapshot from this morning that I can load up." So that might be something you would want to look into. I'm not sure what a "snapshot" of a virtual box is but based on the name, it might be what you're looking for.
The best thing about a boolean is even if you are wrong, you are only off by a bit.

Jason Salmon
Open Dental Software
http://www.opendental.com

teethdood
Posts: 267
Joined: Sun Jul 29, 2007 12:39 am
Location: Visalia, CA
Contact:

Re: virtualbox question

Post by teethdood » Sun Mar 03, 2013 12:11 am

I back up running virtualbox images all the time. A snapshot is just an addendum image to the previous snapshot, recursively all the way back. When backing up a live virtualbox, make a snapshot first. Then you can just copy the directory where the virtualbox image resides. Under linux, you also need to copy the hidden ~./Virtualbox/virtualbox.xml file. Linux hosts require the virtualbox.xml file. Windows hosts don't need it.
Philip H. Doan, DDS
http://www.kaweahdental.com/

User avatar
Justin Shafer
Posts: 596
Joined: Sat Jul 28, 2007 7:34 pm
Location: Fort Worth, TX.

Re: virtualbox question

Post by Justin Shafer » Sun Mar 03, 2013 11:52 am

Just to be safe.. I would plan on scheduling mysql database dumps over the network from the virtualbox to a physical box.. Maybe sync it to a nas. Same with your file shares.

This would allow you to back it up without shutting it down. In case something happens to your snapshot. Bad ram, etc.

bpcomp
Posts: 304
Joined: Mon Feb 27, 2012 7:30 am
Location: Tucson, AZ
Contact:

Re: virtualbox question

Post by bpcomp » Wed Mar 06, 2013 8:34 am

I have done some research on this and we are using VMware to virtualize on top of Linux. After all my research, the conclusion I came to is that it is not a good idea to depend on snapshots for backup. They are a very useful feature when testing updates or trying new software but are not reliable for everyday backup. You should of course do your own research. I scripted a process that suspends the running virtual machine, clones it, and then resumes it. It does this over night and in all my testing, none of the workstations are affected by the server being temporarily unavailable. I am able to restore the full clone anywhere on the network (after shutting down the original server of course) and all the computers see the clone as if it is the original server. This achieves a hardware independent backup that is not just our OD and Imaging data but also our domain server fully configured. It should be fairly easy to adapt my backup scripts for your own use with VirtualBox. If you would like to see my scripts then I would be happy to share them.

jimgaas
Posts: 31
Joined: Fri Aug 12, 2011 5:30 am

Re: virtualbox question

Post by jimgaas » Thu Jul 25, 2013 7:55 am

I run my server in a VM. To do backup, I shut down the services that will lock database files and double click on a .bat file that backs up the important files. You shut down services by right clicking on the computer icon and then go MANAGE and then to the service you wish to stop, ex, MySQL, right click it and select STOP. I shut down MySQL, and a database manager in MS-SQL express that manages the xray database. The .bat file then writes the files to a VM shared drive that can be anywhere. I use Virutalbox. BTW, the services are on the running VM, not on the host and all workstations are off. Any time you do a backup with something running, you run the risk of not getting all the data due to locking. Synchronization is specialized software that stops this problem. Maybe that's what you need. Remember, backing up is only half the equation. You must restore someplace else and try to run what you backed up. You may be in for a surprise if you never do this.

User avatar
Hersheydmd
Posts: 700
Joined: Sun May 03, 2009 9:12 pm

Re: virtualbox question

Post by Hersheydmd » Thu Jul 25, 2013 4:13 pm

jimgaas wrote:I run my server in a VM. To do backup, I shut down the services that will lock database files and double click on a .bat file that backs up the important files.
I would like to do the same thing. Can you automate the shutdown of the services with a script? Can you post the contents of your .bat file?
Robert M Hersh DMD, FAGD
Univ. of Penn 1982
Brooklyn, NY 11234
https://www.facebook.com/pages/Robert-M ... 1471599429

jimgaas
Posts: 31
Joined: Fri Aug 12, 2011 5:30 am

Re: virtualbox question

Post by jimgaas » Fri Jul 26, 2013 1:02 pm

I think you stop most network services like so:

net stop MySQL

This is going to change depending on what you are shutting down. You may need to do a taskkill or something else. If you google it you should find an answer. MySQL is a network service and so it can be killed with net stop. Other services may not work this way.

MySQL is one of the services you must stop. I just do this by hand but I have always thought about adding it to the bat file but never gotten around to it. I am at home at the moment and don't have the bat file handy but I will post the file when I get back to work on Monday. It uses xcopy with about a dozen parameters. It also sets the backup file name with the current date so the backups keep piling up which is how I want it. That way if a backup doesn't work for some reason, like I forgot to shut down the services, I can try the day before. I shut down MySQL and 3 MS-SQL services which handle my Schick xrays. I have never gone to the trouble to see if I really need to shut down all those services but I do know that the back up works and so I have just left it the way it is.

User avatar
Hersheydmd
Posts: 700
Joined: Sun May 03, 2009 9:12 pm

Re: virtualbox question

Post by Hersheydmd » Fri Jul 26, 2013 2:51 pm

That sounds great. I'd love to see your .bat file if you get a chance.
What I've been doing so far is I created a clone of my virtual box server which I have stored on another workstation and on a portable Seagate drive. All the data that resides in that VB server (OD database, Dexis database, Florida Probe database, QB data files, all my images, etc) are backed up daily onto both the cloud (CrashPlan) and the portable Seagate drive. If I had to I could use the clone and restore my latest data backup to it.
Robert M Hersh DMD, FAGD
Univ. of Penn 1982
Brooklyn, NY 11234
https://www.facebook.com/pages/Robert-M ... 1471599429

jimgaas
Posts: 31
Joined: Fri Aug 12, 2011 5:30 am

Re: virtualbox question

Post by jimgaas » Sat Jul 27, 2013 3:25 pm

That is more or less what I do too. I have a clone of my server at home and I take my data update and push it to the clone. Now I have an exact replica of my officer server at home which I could move to the office if I needed to. When I refresh the data on the clone, I can check that everything is there by checking xrays and doing a couple of daysheets. This takes my backup out of the office in case of fire and I have all my data at home for home telephone calls from patients. I can look up allergies, meds, previous treatment, and even xrays. Therefore, I know I have a working backup to depend on in case of emergency. My xrays are about 20 GBytes and the rest is about 5GBytes. I don't backup xrays everyday, but I do try to backup OD qd. In my quest for speedy backup, I have found the little external Seagate USB 3.0 drives to be super fast, way faster that a 3.0 USB thumbdrive. What do you use to backup?

User avatar
Hersheydmd
Posts: 700
Joined: Sun May 03, 2009 9:12 pm

Re: virtualbox question

Post by Hersheydmd » Sat Jul 27, 2013 7:48 pm

I also use the small Seagate portable USB drives. I just bought two new 1 TB external Seagate Backup Plus drives, after Acronis Drive Manager told me that one of my 500 GB external drives was about to fail. Caught it just in time and copied the entire drive to the new drive. I keep one of the external drives connected to my desktop which houses my VB server and CrashPlan, besides backing up to the cloud, also backs up my data (from the Virtual Box) to the external drive. The other one I connect to my network and use MS Briefcase to sync my data files to it and then bring it home.
I also connect regularly to the office with Windows Remote Desktop and occasionally I back up OD through the internet to my home computer. I then check to see that the backup is usable on my home computer, which it always is.
Robert M Hersh DMD, FAGD
Univ. of Penn 1982
Brooklyn, NY 11234
https://www.facebook.com/pages/Robert-M ... 1471599429

jimgaas
Posts: 31
Joined: Fri Aug 12, 2011 5:30 am

Re: virtualbox question

Post by jimgaas » Mon Jul 29, 2013 6:17 am

@echo off

:: variables
set drive=F:\OD-BU
set backupcmd=xcopy /s /c /d /e /h /i /r /y
set folder=%date:~10,4%_%date:~4,2%_%date:~7,2%
::%backupcmd% "D:\Images\*.*" "%drive%\%folder%\Images"
%backupcmd% "D:\OpenDentImages\*.*" "%drive%\%folder%\OpenDentImages"
%backupcmd% "D:\ServerFolders\SharedDocuments\*.*" "%drive%\%folder%\ServerFolders\SharedDocuments"
%backupcmd% "D:\mysql\data\your-database-name\*.*" "%drive%\%folder%\mysql\data\crystallake"

@pause

Here is the bat file I promised I would post. The images directory is commented out because I have two versions of this bat file. One backs up the image directory (20 GBytes) and the other does not. I run the image backup once a week or so because it takes so long. The F drive is a shared drive of the VM. The set folder line is the line that places a date on the backed up folder so they don't get over written. The ServerFolders\SharedDocuments folder has all the scanned EOB's and other paper scans. I can't remember what all the parameters mean on the xcopy command but you an look them up on the web. It basically doesn't copy a file that already exists with an unchanged date, ie, it doesn't recopy xrays but it does copy the msyql files that, even though they are named the same, have changed. You can add net stop MySQL at the beginning to stop the MySQL service automatically. If you want to test whether or not it is working, open a command winow by typing cmd in the run window of the start button. When the command window comes up, type "net stop MySQL." The command window responds that the service has been stopped. It can be started the same way, ie net start MySQL. You need to figure out any other services that you must stop and other files that are particular to you office, namely your xrays and what you do with EOB's, etc.

User avatar
Hersheydmd
Posts: 700
Joined: Sun May 03, 2009 9:12 pm

Re: virtualbox question

Post by Hersheydmd » Mon Jul 29, 2013 7:28 am

Two questions.
MySQL & OD are on my VM server, as is my image folder and all my other data that I want to backup.
My backup drive gets plugged into the host machine.
Do I run the .bat file on the host or on the VM (Vitual Box), and can I stop MySQL on the VM from a command on the host? I haven't had luck getting the external drive to work with both the host and the VM, so I disabled it on the VM.
Robert M Hersh DMD, FAGD
Univ. of Penn 1982
Brooklyn, NY 11234
https://www.facebook.com/pages/Robert-M ... 1471599429

bpcomp
Posts: 304
Joined: Mon Feb 27, 2012 7:30 am
Location: Tucson, AZ
Contact:

Re: virtualbox question

Post by bpcomp » Mon Jul 29, 2013 7:43 am

The bat file would be easiest to run from the guest where all the data resides. I think it's possible to run from the host but I'm not 100% that it would all work. Either way the bat files needs access to the files in question AND the USB drive, so you either hook the USB drive up to the guest or copy all the files to the host and then copy to the USB.

Look into vmrun for stopping SQL from the host.

You cannot have the USB drive connected to both the host and the guest. It must be controlled by one or the other.

All this to say that stopping SQL, running the BAT file, and copying files to the USB are all done most easily from the guest.

jimgaas
Posts: 31
Joined: Fri Aug 12, 2011 5:30 am

Re: virtualbox question

Post by jimgaas » Mon Jul 29, 2013 8:44 am

Everything is on the VM, all services, all files to be backed up, the bat file, everything. Stop all the services that will interfere with your backup. Place the bat file on the desktop of your VM. Right click the bat file and select "Edit." Change the bat file to back up your special files and change the bat file to reflect your backup location. I backup to a shared drive that I have mapped to a drive letter (I think it is F:). I would recommend backing up this way, otherwise you have to make the VM recognize you backup drive and the host wants to see it first. Once the backed up files are on the host, I can back up with a USB 3.0 drive and it is much faster. You can add net stop MySQL to the bat file to stop the MySQL service and any other services you would like to stop. You can type cmd in the run box of the start button and type "net stop MySQL" into the box and watch the service stop. You can start it back up with net start MySQL. Don't do this when your office is using the database since you will cut everyone off from the services of the OD database. It is best to do this home with a clone to see how everything works or after work when all the workstations are down.

User avatar
Hersheydmd
Posts: 700
Joined: Sun May 03, 2009 9:12 pm

Re: virtualbox question

Post by Hersheydmd » Tue Jul 30, 2013 5:12 am

Thanks. All great advice & instructions. Will give it a try soon.
Robert M Hersh DMD, FAGD
Univ. of Penn 1982
Brooklyn, NY 11234
https://www.facebook.com/pages/Robert-M ... 1471599429

User avatar
Manny Ramirez
Posts: 129
Joined: Tue Mar 06, 2012 3:07 pm
Location: Miami/Puerto Rico
Contact:

Re: virtualbox question

Post by Manny Ramirez » Wed Jul 31, 2013 9:38 pm

Why don't you guys just install Cobian Backup in your VM ? Cobian has all the tools you need to stop and start the database. You can automate the whole process :) In regards to VM disaster recovery plan. Just stop the machine. Copy the files of your VM to an external drive. If the VM gets corrupted for any reason, all you have to do is copy the file back to your host computer. Create a new VM, point to the vhd file and Crank it up. The worst thing that can happen is that Windows will ask you to register. If you have snapshots, make sure you copy those too, as this will be necessary to restore your machine. Do not use snapshot as backups. Bad idea.
Manny Ramirez
Senior Network Engineer
E-ssential Networks LLC

jimgaas
Posts: 31
Joined: Fri Aug 12, 2011 5:30 am

Re: virtualbox question

Post by jimgaas » Thu Aug 01, 2013 11:18 am

Cobian looks like great software. I will have to give it a try. The only time I seem to end up with a vhd file is when I virtualize a running machine. My personal desktop machine just started to go bad so I virtualized it because it had so much stuff on it. I didn't want to reinstall tons of stuff I don't even have disks for anymore. I wound up with a vhd of the xp machine that was my desktop and now I run it on an Ubuntu 13.04 drive. I prefer Virtualbox over VMware and so most of my VM's are vdi because this is the default of Virtualbox. They are not as easy to point and shoot at. With vdi files you really must import and export appliances. All my workstations have an appliance on the desktop that I can reload in a pinch. It is not feasible to easily mix and match always because if you use the appliance from one machine on in different operatory, you will need to reset the NIC. If you don't, you will have two machines on your network that both have the same Network Interface Card number and therefore both will receive the information that is intended for only one of them. Importing and export appliances takes a long time. When you import an appliance in virutalbox it asks if you want to use the same NIC or a different one. If it is on the same machine (the same Op), you don't need to change it, otherwise you should change it. I think this can trigger a revalidation by Microsoft.

With workstations the very quickest way to get back up and running is to have at least two VM's that can be selected in Virtualbox. If one goes bad, just run the other one and fix the broken one when there is time. You can't do that on the server because you won't have the data updated. A clone of the server (host and VM) will work quickly if there is back up data. This is where everyone wants to go with RAID 1. If one of the disks goes bad, you can hot swap out to the another one and it will rebuild. If you computer goes bad, and Linux is your host, just move the disk to different hardware and off you go. If Windows is your host, you need to have the appliance on a different machine that can take the place of your server and you must update the data. RAID is cumbersome to work with but I found a small disk enclosure at Microcenter that is the size of a 3.5" drive but holds two 2.5" drives. You can set it to RAID 0 or 1 on a switch and then format it like any drive, instead of a RAID format which is really a hassle. I just bought one of these and put two 2.5" hybrid drives into the enclosue. It is Linux with my server as a VM. Linux boots almost instantly. My only complaint is that when I removed one of the drives to see what kind of dead disk warning I would get, I didn't get any warning at all. NOT GOOD.

User avatar
Justin Shafer
Posts: 596
Joined: Sat Jul 28, 2007 7:34 pm
Location: Fort Worth, TX.

Re: virtualbox question

Post by Justin Shafer » Mon Sep 16, 2013 10:57 pm

Cobian... sounds neat...

User avatar
Hersheydmd
Posts: 700
Joined: Sun May 03, 2009 9:12 pm

Re: virtualbox question

Post by Hersheydmd » Tue Nov 26, 2013 8:46 pm

I installed Virtual Box on two identical computers that I upgraded to Windows 8.
I am backing up the data drive on my VB server with Crashplan to the web. It is running constantly.
I also back up the C:\Users\Robert folder on the host (which contains the VirtualBox VMs & the .VirtualBox folders) with Crashplan to the web and to an external harddrive.
What is the simplest way to create a copy of the VB server on the second computer, so if the server crashes I can rename the other machine and have it take over?
Should I use "Export Appliance"
Or, use the Virtual Media Manager to copy the hard drive (.vdi file)
Or, just use windows to copy the VirtualBox VMs folder to the other computer? What about the .VirtualBox folder?
Can this be done while the guest is running?
I read somewhere that there may be a problem running a copy of Windows on another host, that it won't be recognized as a legitimate copy of Windows?
Robert M Hersh DMD, FAGD
Univ. of Penn 1982
Brooklyn, NY 11234
https://www.facebook.com/pages/Robert-M ... 1471599429

teethdood
Posts: 267
Joined: Sun Jul 29, 2007 12:39 am
Location: Visalia, CA
Contact:

Re: virtualbox question

Post by teethdood » Wed Nov 27, 2013 5:07 pm

Simplest: Copy the Virtualbox VM folder to the 2nd computer either across the network (if you have a 1Gbps network) or via external HDD at the end of the day. The VM can continue running while you are copying (I've tested this multiple times, try it for yourself), although I wouldn't use OD or anything.

You don't need the .Virtualbox folder for windows, only necessary under Linux.

You don't need to rename anything. The VM will simply boot up to its original assigned name (ie "server") and you are good to go.

The VM will function normally as a legitimate copy of windows. You can make as many copies as you want. It's only illegal if you boot up multiple instances. The only hiccup I've seen seldomly is software that's attached to the network card (ie XDR) will make you re-register if switching to another computer with a different network card. That all depends on how you config the VM's network and is rare that it does that. Again, make sure you try it for yourself to make sure it works the way you want it. Don't take my word for it... test it and test it some more.
Philip H. Doan, DDS
http://www.kaweahdental.com/

User avatar
Hersheydmd
Posts: 700
Joined: Sun May 03, 2009 9:12 pm

Re: virtualbox question

Post by Hersheydmd » Wed Nov 27, 2013 5:19 pm

Sounds great Phil. I am going to give it a try.
My VM is 140 Gigs, so it may take a while. Will let you know how it worked out.
Robert M Hersh DMD, FAGD
Univ. of Penn 1982
Brooklyn, NY 11234
https://www.facebook.com/pages/Robert-M ... 1471599429

User avatar
Hersheydmd
Posts: 700
Joined: Sun May 03, 2009 9:12 pm

Re: virtualbox question

Post by Hersheydmd » Thu Nov 28, 2013 5:57 am

Copied the folder from Computer A to Computer B. Opened VB, but didn't see any VM's listed on the new computer. So I created a new VM and I attached the .vdi file that was in the new VirtualBox VM folder. Everything worked great, except that it says my copy of Windows in the new VM is not authenticated. It says "This product key is already being used on another PC. Try a different key or buy a new one." What do you do. This is just an emergency backup. I don't want to buy a new license for every backup.
Robert M Hersh DMD, FAGD
Univ. of Penn 1982
Brooklyn, NY 11234
https://www.facebook.com/pages/Robert-M ... 1471599429

teethdood
Posts: 267
Joined: Sun Jul 29, 2007 12:39 am
Location: Visalia, CA
Contact:

Re: virtualbox question

Post by teethdood » Fri Nov 29, 2013 11:51 am

Instead of creating a new VM and attaching the vdi, try "Adding". (Machine Menu | Add | Point to the .vbox file) That way all the settings are the same (check anyway). In addition, shut down the virtual machine running on physical machine A first before running the copied VM. Should work
Philip H. Doan, DDS
http://www.kaweahdental.com/

Post Reply