I cannot figure out how to backup

Discussions related to using VirtualBox on Linux hosts.
Post Reply
CWM030
Posts: 5
Joined: 2. Jun 2018, 11:33

I cannot figure out how to backup

Post by CWM030 »

HI,

I am needing directions on how do I back up my whole Windows 7 image in Kubuntu 18.04?

I've tried googling and there's so many answer's I cannot tell which method's are right and which method's are incorrect.
I really don't have the time to mess up the VM and have to set it back up all over again.

Thanks,
Chris
socratis
Site Moderator
Posts: 27330
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: I cannot figure out how to backup

Post by socratis »

See the FAQ "Moving a VM" and interpret it as "Backing up / Copying a VM".
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
WFV
Posts: 82
Joined: 7. Mar 2016, 13:28
Primary OS: Linux other
VBox Version: OSE other
Guest OSses: ArchLinux; Fedora; Ubuntu; Win7pro64; WinXP
Contact:

Re: I cannot figure out how to backup

Post by WFV »

I use rsync in my Linux Host to backup my VirtualBox guests. My host isn't Kbuntu, but rysnc should work in any Linux distro. It works great, have restored guest with rsync (just set the reverse order of from/to in the rsync command).
For example: I want to backup my WIndows 7 pro 64bit guest os to my internal backup drive (this also works for backing up to external drives, just have to know the path to the external drive etc):

Code: Select all

# rsync -aAXhv --delete --progress /home/USER/VirtualBox\ VMs/GUEST/ /mnt/INTERNAL_BACKUP_LOCATION/home/USER/VirtualBox\ VMs/GUEST/
whereas:
USER is your home/user directory, maybe yours is /home/CWM030
GUEST is the name of the VirtualBox guest directory you are backing up, in my case it is "Win7pro64" no quotes
INTERNAL_BACKUP_LOCATION is the backup directory, in my case its simply "/mnt/backups/..."
for an external drive, the location might be something like /run/media/BACKUP/ e.g. whatever you name your backup directory.
Note: my internal backup directory is on its own hard drive.
For backing up all the guests

Code: Select all

# rsync -aAXhv --delete --progress /home/USER/VirtualBox\ VMs/ /mnt/INTERNAL_BACKUP_LOCATION/home/USER/VirtualBox\ VMs/
All of this is assuming Kbuntu installs the VirtualBox guests to

Code: Select all

/home/you/VirtualBox VMs
otherwise rsync is generally

Code: Select all

 rysnc [OPERAND] [OPTIONS] /path/of/desired/directory/ /path/to/backup/desired/directory/
I also backup the "dot VirtualBox" folder whenever VirtualBox package is updated.
I've been told I don't need all of the operands I use, and I haven't read up on rsync in a long time. They work for me so I keep using them. I'm sure more advanced users could streamline these commands however, once the backup starts, its only going to run as fast as your slowest piece of involved hardware no matter how the command sets it in motion.
Last edited by WFV on 2. Jun 2018, 21:42, edited 1 time in total.
CWM030
Posts: 5
Joined: 2. Jun 2018, 11:33

Re: I cannot figure out how to backup

Post by CWM030 »

Hello,

I will try to answer your questions 1 at a time:


1.USER is your home/user directory, maybe yours is /home/CWM030

Actually it would be.... /home/chris/


GUEST is the name of the VirtualBox guest directory you are backing up, in my case it is "Win7pro64" no quotes

Would the guest directory be:

/home/chris/VirtualBox VMs/



INTERNAL_BACKUP_LOCATION is the backup directory, in my case its simply "/mnt/backups/..."

For me I believe that would be:
/home/chris/Desktop/SpiderOak Hive/BACKUPS/SOFTWARE/VIRTUALBOX/


And then the command I would run would be:

rsync -aAXhv --delete --progress /home/chris/VirtualBox\ VMs/ /home/chris/SpiderOak Hive/BACKUPS/SOFTWARE/VIRTUALBOX/ ???

Thanks,
Chris
WFV
Posts: 82
Joined: 7. Mar 2016, 13:28
Primary OS: Linux other
VBox Version: OSE other
Guest OSses: ArchLinux; Fedora; Ubuntu; Win7pro64; WinXP
Contact:

Re: I cannot figure out how to backup

Post by WFV »

for the first run, in order for rsync to create the folder "VirtualBox VMs" it will be:

Code: Select all

rsync -aAXhv --delete --progress /home/chris/VirtualBox\ VMs /home/chris/SpiderOak\ Hive/BACKUPS/SOFTWARE/VIRTUALBOX/
Notice I removed the trailing / from the input location. This will create the "VirtualBox VMs" folder in your /home/chris/SpiderOak Hive/BACKUPS/SOFTWARE/VIRTUALBOX/ directory
including all folders and files contained in "VirtualBox VMs" e.g. all your guests, logs etc.
Also notice that folder names with a space in them, you need to use the backslash "SpiderOak\ Hive" otherwise rsync will interpret the space as the start of another operation and will error as it will think the next operation is a command.
You can do a "dry run" meaning rsync will run and show you what it will do without actually creating a backup. The benefit to this is that if the command is incorrect, it will error so you can troubleshoot/correct it before executing live.
To do so simply append n to the -aAXhv operand, e.g.

Code: Select all

-aAXhvn.
For backing up afterwards - this will overwrite the existing backup each time - run rsync as follows:

Code: Select all

rsync -aAXhv --delete --progress /home/chris/VirtualBox\ VMs/ /home/chris/SpiderOak\ Hive/BACKUPS/SOFTWARE/VIRTUALBOX/VirtualBox\ VMs/
I'd also recommend that your backup not reside on the same drive as VirtualBox. This way you still have a true backup if the /home drive fails, it can be used to restore to a new drive etc.
CWM030
Posts: 5
Joined: 2. Jun 2018, 11:33

Re: I cannot figure out how to backup

Post by CWM030 »

OH CRAP!

I just ran that command while the VM was HOT. I forgot that the VM was running on desktop 6.

That won't hurt the VM since it was " HOT" will it? I closed the Konsole window real quick.. I just installed Windows 7 and was running initial updates.

Thanks,
CM
socratis
Site Moderator
Posts: 27330
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: I cannot figure out how to backup

Post by socratis »

CWM030 wrote:That won't hurt the VM since it was " HOT" will it?
It won't hurt your VM on the host, but your backup may be incomplete/corrupted for that specific VDI only. It depends on what the VM was doing at the time.
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
WFV
Posts: 82
Joined: 7. Mar 2016, 13:28
Primary OS: Linux other
VBox Version: OSE other
Guest OSses: ArchLinux; Fedora; Ubuntu; Win7pro64; WinXP
Contact:

Re: I cannot figure out how to backup

Post by WFV »

As socratis mentioned, you might end up with a corrupt backup of that specific VDI, it won't hurt the live guest nor the host. It really depends on what the live guest is doing at the time that rsync is run - rsync itself won't hurt or corrupt anything but the backup will be of a different state than the live version. I definitely wouldn't do it while the guest is in the process of updating its operating system or any of its apps as might end up with a useless backup. I encourage you to read the rsync man pages if you are going to use it - rsync does a lot of thorough checks while backing up data. Normally I close all my guests when I run rsync to back them up, but it isn't required - but do consider what the guest is doing at the time rsync is ran. The guest doing little to nothing when rsync'ing it is preferred if you can't or don't want to close the guest (doesn't matter what the Windows guest is doing in its normal background - not normal background would be OS updates, etc). Also stopping rsync while it is running doesn't do any harm, you'll have an incomplete backup or no backup, in the Konsole do:

Code: Select all

CTRL+C
What I like about rsync backups, say I install some software in the Windows guest, and then decide I don't want it and don't want all the garbage leftover from typical WIndows uninstall said software. Providing I have a fairly current rsync'd backup (best if at least in same version of VirtualBox), I simply close the guest, then rsync reverse order "from/to" the backup, Then reopen the guest and voila', software gone, no leftovers :D
CWM030
Posts: 5
Joined: 2. Jun 2018, 11:33

Re: I cannot figure out how to backup

Post by CWM030 »

One last question:

Does it matter if SO is running and backing up as the rsync command is running?

Thanks,
Chris
WFV
Posts: 82
Joined: 7. Mar 2016, 13:28
Primary OS: Linux other
VBox Version: OSE other
Guest OSses: ArchLinux; Fedora; Ubuntu; Win7pro64; WinXP
Contact:

Re: I cannot figure out how to backup

Post by WFV »

don't know what you mean by "SO is running..."
rsync can run when lots of other things are running on the host providing you have the resources to handle everything - I think what we are discussing here are ways to backup VDI's. What you're generally after in a backup is to get good clean reliable backups. That being said, if the guest is running when you rsync it, for optimal results make sure the guest isn't doing any critical work (like system updates) - it doesn't matter at all what the host is doing unless for some reason rsync and some other host application are competing for the same data or write location? in which case even then I'd expect linux to handle it without issue by cpu, disk, or IO schedulers or whatever else linux uses to share resources. rysnc is one option for backing up your guests, socratis provided another in the second post.
CWM030
Posts: 5
Joined: 2. Jun 2018, 11:33

Re: I cannot figure out how to backup

Post by CWM030 »

SO = Spider Oak ( My backup software)

-- Chris
Last edited by socratis on 3. Jun 2018, 14:14, edited 1 time in total.
Reason: Removed unnecessary verbatim quote of the whole previous message.
WFV
Posts: 82
Joined: 7. Mar 2016, 13:28
Primary OS: Linux other
VBox Version: OSE other
Guest OSses: ArchLinux; Fedora; Ubuntu; Win7pro64; WinXP
Contact:

Re: I cannot figure out how to backup

Post by WFV »

if spideroak can back up the VirtualBox VMs folder to somewhere then there's no reason to run rsync or any other backup program it seems, otherwise I have no idea what happens when 2 backup programs run at same time, never tried it, never had a need to. My guess is that if they're both using the same tools to do the job, one might have to wait for the other...
Post Reply