Closed t0X1n88 closed 2 years ago
Hi @t0X1n88 ,
Happy to help. Where did you save the "Start Backup" file and what is the filename (+extension)?
Thank you very much. I have put Start Backup in folder "D:\Server VM\VirtualBox-Backup-master" with extension .bat as was original Example Start.bat.
It may not be related, but I noticed that could point to why this is not working. If I start VBoxManage it acts similarly. It opens a cmd and writes some text, but it closes immediately, so I can't see what is written there. I Also noticed that in my VirtualBox if I go under preferences, go under tab General and check Default Machine Folder it points to folder "C:\Users\eventserver\VirtualBox VMs". However this folder does not exist.
After some checking I found this folder, which contains VirtualBox VM's:
I do not dare to change these settings, so I did not yet test if this affects script. But It was suspicious enough for me to mention it :)
I'll try to recreate your setup and will get back to you.
I believe I've found the (or at least an) issue. I tried to run the Start Backup.bat
directly from a command line as followed:
C:\Users\Niels> "D:\Server VM\VirtualBox-Backup-master\Start Backup.bat"
This resulted in a lot of errors like this (at least for me)
'cscript' is not recognized as an internal or external command, operable program or batch file.
Can you confirm that you are getting the same type of errors when you run the same from a command prompt? Be sure to include the double quotations.
Assuming this is the case:
Edit the Start Backup.bat
file and modify accordingly:
:: Example - Modify according to your needs
cd "%SystemRoot%\System32"
"%_VBBACKUP%" --backupdir "D:\Backup" --backupmode acpipowerbutton --prefix "Daily Backup" --keep 7
This resolved the 'cscript'
issue for me.
I have tried running it as you have suggested and now I can see an issue. It is not the one you have described, however I do not know what to do with this :) It is an error with "No destination folder." But as far as I know this is correctly defined.
As you can see I have added compress -1 as it helped other user(I checked previously opened issues).
Can you copy the entire content of the command prompt and share it please.
For reference, here's mine from when I ran "D:\Server VM\VirtualBox-Backup-master\Start Backup.bat"
:
Starting VirtualBox Backup...
"Eventnikice - Linux" {1820131a-8751-4583-9a2a-9cd6229ff9a5}
Parameters...
Backup Folder: D:\Backup
Backup Mode: acpipowerbutton
Prefix: Daily Backup
Compress: Disabled
Keep: 1
Stack: False
Eventnikice - Linux
VM state: poweroff
Creating Snapshot...
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Snapshot taken. UUID: d4a67115-46c4-4b8d-8ad7-3d69298d9c92
Copy...
-------------------------------------------------------------------------------
ROBOCOPY :: Robust File Copy for Windows
-------------------------------------------------------------------------------
Started : maandag 6 december 2021 10:16:32
Source : D:\Server VM\Eventnikice - Linux\
Dest : C:\Users\Niels\AppData\Local\Temp\1820131a-8751-4583-9a2a-9cd6229ff9a5\
Files : *.*
Options : *.* /S /E /DCOPY:DA /COPY:DAT /R:1000000 /W:30
------------------------------------------------------------------------------
New Dir 3 D:\Server VM\Eventnikice - Linux\
100% New File 7996 Eventnikice - Linux.vbox
100% New File 7996 Eventnikice - Linux.vbox-prev
100% New File 22.4 g Kali Linux.vdi
New Dir 2 D:\Server VM\Eventnikice - Linux\Logs\
100% New File 197730 VBox.log
100% New File 647004 VBoxHardening.log
New Dir 1 D:\Server VM\Eventnikice - Linux\Snapshots\
100% New File 2.0 m {2c0695d8-1aa2-43dc-af3f-5ddd0e5d67e0}.vdi
------------------------------------------------------------------------------
Total Copied Skipped Mismatch FAILED Extras
Dirs : 3 3 0 0 0 0
Files : 6 6 0 0 0 0
Bytes : 22.476 g 22.476 g 0 0 0 0
Times : 0:02:00 0:02:00 0:00:00 0:00:00
Speed : 199657809 Bytes/sec.
Speed : 11424.511 MegaBytes/min.
Ended : maandag 6 december 2021 10:18:33
Deleting Snapshot...
Deleting snapshot 'Daily Backup 2021.12.06-10.16' (d4a67115-46c4-4b8d-8ad7-3d69298d9c92)
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Moving...
-------------------------------------------------------------------------------
ROBOCOPY :: Robust File Copy for Windows
-------------------------------------------------------------------------------
Started : maandag 6 december 2021 10:18:33
Source : C:\Users\Niels\AppData\Local\Temp\1820131a-8751-4583-9a2a-9cd6229ff9a5\
Dest : D:\Backup\Eventnikice - Linux\Daily Backup 2021.12.06-10.16\
Files : *.*
Options : *.* /S /E /DCOPY:DA /COPY:DAT /MOVE /R:1000000 /W:30
------------------------------------------------------------------------------
New Dir 3 C:\Users\Niels\AppData\Local\Temp\1820131a-8751-4583-9a2a-9cd6229ff9a5\
100% New File 7996 Eventnikice - Linux.vbox
100% New File 7996 Eventnikice - Linux.vbox-prev
100% New File 22.4 g Kali Linux.vdi
New Dir 2 C:\Users\Niels\AppData\Local\Temp\1820131a-8751-4583-9a2a-9cd6229ff9a5\Logs\
100% New File 197730 VBox.log
100% New File 647004 VBoxHardening.log
New Dir 1 C:\Users\Niels\AppData\Local\Temp\1820131a-8751-4583-9a2a-9cd6229ff9a5\Snapshots\
100% New File 2.0 m {2c0695d8-1aa2-43dc-af3f-5ddd0e5d67e0}.vdi
------------------------------------------------------------------------------
Total Copied Skipped Mismatch FAILED Extras
Dirs : 3 3 0 0 0 0
Files : 6 6 0 0 0 0
Bytes : 22.476 g 22.476 g 0 0 0 0
Times : 0:01:54 0:01:54 0:00:00 0:00:00
Speed : 210753784 Bytes/sec.
Speed : 12059.428 MegaBytes/min.
Ended : maandag 6 december 2021 10:20:28
Cleanup...
Eventnikice - Linux done!
C:\Users\Niels>
FYI: you can use the triple backstick ```
before and after your block to separate it from the rest of the text.
Actually I am not getting any more than I posted in my previous response :) This is everything from Command prompt.
That's weird. What is the output when you run this command?
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" list vms
This is the output: Which is correct, because I have two VM's setup. But only one is running for now.
Can you try running this command directly from the command line like this and share the output.
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" showvminfo {d14debd3-d8eb-47b1-bbf6-3b9e633cb8ff} --machinereadable
as well as for this command:
"D:\Server VM\VirtualBox-Backup-master\VirtualBox Backup.bat" --backupdir "D:\Backup" --backupmode acpipowerbutton --prefix "Daily Backup" --compress -1 --keep 7
I ran first command and got following output: Microsoft Windows [Version 10.0.19043.1348] (c) Microsoft Corporation. All rights reserved.
C:\Users\eventserver>"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" showvminfo {d14debd3-d8eb-47b1-bbf6-3b9e633cb8ff} --machinereadable
name="Eventnikice - Linux"
groups="/"
ostype="Other Linux (64-bit)"
UUID="d14debd3-d8eb-47b1-bbf6-3b9e633cb8ff"
CfgFile="D:\\Server VM\\Eventnikice - Linux\\Eventnikice - Linux.vbox"
SnapFldr="D:\\Server VM\\Eventnikice - Linux\\Snapshots"
LogFldr="D:\\Server VM\\Eventnikice - Linux\\Logs"
hardwareuuid="d14debd3-d8eb-47b1-bbf6-3b9e633cb8ff"
memory=16000
pagefusion="off"
vram=16
cpuexecutioncap=100
hpet="off"
cpu-profile="host"
chipset="piix3"
firmware="BIOS"
cpus=4
pae="on"
longmode="on"
triplefaultreset="off"
apic="on"
x2apic="on"
nested-hw-virt="off"
cpuid-portability-level=0
bootmenu="messageandmenu"
boot1="floppy"
boot2="dvd"
boot3="disk"
boot4="none"
acpi="on"
ioapic="on"
biosapic="apic"
biossystemtimeoffset=0
rtcuseutc="on"
hwvirtex="on"
nestedpaging="on"
largepages="on"
vtxvpid="on"
vtxux="on"
paravirtprovider="default"
effparavirtprovider="kvm"
VMState="running"
VMStateChangeTime="2021-12-05T13:55:39.017000000"
graphicscontroller="vmsvga"
monitorcount=1
accelerate3d="off"
accelerate2dvideo="off"
teleporterenabled="off"
teleporterport=0
teleporteraddress=""
teleporterpassword=""
tracing-enabled="off"
tracing-allow-vm-access="off"
tracing-config=""
autostart-enabled="off"
autostart-delay=0
defaultfrontend=""
vmprocpriority="default"
storagecontrollername0="IDE"
storagecontrollertype0="PIIX4"
storagecontrollerinstance0="0"
storagecontrollermaxportcount0="2"
storagecontrollerportcount0="2"
storagecontrollerbootable0="on"
"IDE-0-0"="D:\Server VM\Eventnikice - Linux\Eventnikice - Linux.vhd"
"IDE-ImageUUID-0-0"="b880d374-7533-460c-818c-bfe4d9fe86d8"
"IDE-0-1"="none"
"IDE-1-0"="emptydrive"
"IDE-IsEjected"="off"
"IDE-1-1"="none"
bridgeadapter1="Realtek PCIe GbE Family Controller"
macaddress1="08002723CDBC"
cableconnected1="on"
nic1="bridged"
nictype1="82540EM"
nicspeed1="0"
nic2="none"
nic3="none"
nic4="none"
nic5="none"
nic6="none"
nic7="none"
nic8="none"
hidpointing="usbtablet"
hidkeyboard="ps2kbd"
uart1="off"
uart2="off"
uart3="off"
uart4="off"
lpt1="off"
lpt2="off"
audio="dsound"
audio_out="on"
audio_in="off"
clipboard="disabled"
draganddrop="disabled"
SessionName="GUI/Qt"
VideoMode="1680,1050,32"@0,0 1
vrde="off"
usb="on"
ehci="off"
xhci="off"
VRDEActiveConnection="off"
VRDEClients==0
videocap="off"
videocapaudio="off"
capturescreens="0"
capturefilename="D:\\Server VM\\Eventnikice - Linux\\Eventnikice - Linux.webm"
captureres="1024x768"
capturevideorate=512
capturevideofps=25
captureopts=""
GuestMemoryBalloon=0
GuestOSType="Linux26_64"
GuestAdditionsRunLevel=1
GuestAdditionsVersion="6.0.0 r127566"
GuestAdditionsFacility_VirtualBox Base Driver=50,1638712549976
GuestAdditionsFacility_Seamless Mode=0,1638712549976
GuestAdditionsFacility_Graphics Mode=0,1638712549976
When second command was run I got same output as before:
I can see an extra whitespace in the path (on the CfgFile property), it's used to determine the folder to copy from. Can you try renaming the VM to something without any special characters (like the - ) and retry. That should also move the files to a new folder.
I have renamed a folder where machine is being saved and also I changed name of VM. Here is the information:
Microsoft Windows [Version 10.0.19043.1348]
(c) Microsoft Corporation. All rights reserved.
C:\Users\eventserver>"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" showvminfo {d14debd3-d8eb-47b1-bbf6-3b9e633cb8ff} --machinereadable
name="EventnikiceLinux"
groups="/"
ostype="Other Linux (64-bit)"
UUID="d14debd3-d8eb-47b1-bbf6-3b9e633cb8ff"
CfgFile="D:\\ServerVM\\EventnikiceLinux\\EventnikiceLinux.vbox"
SnapFldr="D:\\ServerVM\\EventnikiceLinux\\Snapshots"
LogFldr="D:\\ServerVM\\EventnikiceLinux\\Logs"
hardwareuuid="d14debd3-d8eb-47b1-bbf6-3b9e633cb8ff"
memory=16000
pagefusion="off"
vram=16
cpuexecutioncap=100
hpet="off"
cpu-profile="host"
chipset="piix3"
firmware="BIOS"
cpus=4
pae="on"
longmode="on"
triplefaultreset="off"
apic="on"
x2apic="on"
nested-hw-virt="off"
cpuid-portability-level=0
bootmenu="messageandmenu"
boot1="floppy"
boot2="dvd"
boot3="disk"
boot4="none"
acpi="on"
ioapic="on"
biosapic="apic"
biossystemtimeoffset=0
rtcuseutc="on"
hwvirtex="on"
nestedpaging="on"
largepages="on"
vtxvpid="on"
vtxux="on"
paravirtprovider="default"
effparavirtprovider="kvm"
VMState="poweroff"
VMStateChangeTime="2021-12-07T15:03:26.000000000"
graphicscontroller="vmsvga"
monitorcount=1
accelerate3d="off"
accelerate2dvideo="off"
teleporterenabled="off"
teleporterport=0
teleporteraddress=""
teleporterpassword=""
tracing-enabled="off"
tracing-allow-vm-access="off"
tracing-config=""
autostart-enabled="off"
autostart-delay=0
defaultfrontend=""
vmprocpriority="default"
storagecontrollername0="IDE"
storagecontrollertype0="PIIX4"
storagecontrollerinstance0="0"
storagecontrollermaxportcount0="2"
storagecontrollerportcount0="2"
storagecontrollerbootable0="on"
"IDE-0-0"="D:\ServerVM\EventnikiceLinux\Eventnikice - Linux.vhd"
"IDE-ImageUUID-0-0"="b880d374-7533-460c-818c-bfe4d9fe86d8"
"IDE-0-1"="none"
"IDE-1-0"="emptydrive"
"IDE-IsEjected"="off"
"IDE-1-1"="none"
bridgeadapter1="Realtek PCIe GbE Family Controller"
macaddress1="08002723CDBC"
cableconnected1="on"
nic1="bridged"
nictype1="82540EM"
nicspeed1="0"
nic2="none"
nic3="none"
nic4="none"
nic5="none"
nic6="none"
nic7="none"
nic8="none"
hidpointing="usbtablet"
hidkeyboard="ps2kbd"
uart1="off"
uart2="off"
uart3="off"
uart4="off"
lpt1="off"
lpt2="off"
audio="dsound"
audio_out="on"
audio_in="off"
clipboard="disabled"
draganddrop="disabled"
vrde="off"
usb="on"
ehci="off"
xhci="off"
videocap="on"
videocapaudio="off"
capturescreens="0"
capturefilename="D:\\ServerVM\\EventnikiceLinux\\EventnikiceLinux.webm"
captureres="1024x768"
capturevideorate=512
capturevideofps=25
captureopts="vc_enabled=true,ac_enabled=false,ac_profile=med"
GuestMemoryBalloon=0
However I still get same output if I run command: "D:\ServerVM\VirtualBox-Backup-master\VirtualBox Backup.bat" --backupdir "D:\Backup" --backupmode acpipowerbutton --prefix "Daily Backup" --compress -1 --keep 7
Frustrating...
Have you tried every other combination of parameters, different backup location, something on C:\ perhaps?
Start Backup.bat
file.--compress
parameter to -1
didn't helpI'll write out what the script does in order so that you can follow along, to see where it does wrong.
In such a way that it can be reproduced manually. I'm skipping the parts that do not apply, like the include
and exclude
parameters.
The script starts by extracting the parameters pass to the VirtualBox Backup.bat
file. This we obviously can't re-produce as we'll be doing all of the commands manually. Never the less, here are some of the variables that are created in this stage. We'll use them later.
BACKUPDIR - "D:\Backup"
(from the parameters)
BACKUPMODE - acpipowerbutton
(from the parameters)
PREFIX - "Daily Backup"
(from the parameters)
COMPRESS - -1
(from the parameters)
KEEP - 7
(from the parameters)
Now run the following command and copy the result into an empty notepad.
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" list vms
The ID of the VM is the important part, you've used it before. From your last comment it was d14debd3-d8eb-47b1-bbf6-3b9e633cb8ff
Now run the following command and copy the result to the notepad.
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" showvminfo {d14debd3-d8eb-47b1-bbf6-3b9e633cb8ff} --machinereadable
Look for the property VMState
, if it is running
, run the following command to shut it down.
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" controlvm {d14debd3-d8eb-47b1-bbf6-3b9e633cb8ff} acpipowerbutton
Now we'll run the command to create the snapshot:
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" snapshot {d14debd3-d8eb-47b1-bbf6-3b9e633cb8ff} take "TEST_BACKUP" --live
.. and restart the VM (if it was running) with this command
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" startvm {d14debd3-d8eb-47b1-bbf6-3b9e633cb8ff} --type headless
Now we can copy the VM to a temp folder. Be sure to include the .
at the end of the VM's path.
The VM's path is pulled from the showvminfo
results, it get's it from the CfgFile
property. Base on your last comment that would be D:\ServerVM\EventnikiceLinux
ROBOCOPY "D:\ServerVM\EventnikiceLinux." "%TEMP%\{d14debd3-d8eb-47b1-bbf6-3b9e633cb8ff}" /E
This should copy the content of the VM's folder to your TEMP folder in C:\Users\eventserver\AppData\Local\Temp\{d14debd3-d8eb-47b1-bbf6-3b9e633cb8ff}
Now you can delete the snapsh0t that we took with
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" snapshot {d14debd3-d8eb-47b1-bbf6-3b9e633cb8ff} delete "TEST_BACKUP"
Now it will either compress the files into a .7z
archive or move them to the destination. We'll stick with moving them for this example. The VM's name is used from the showvminfo
results, it get's it from the name
property.
ROBOCOPY "%TEMP%\{d14debd3-d8eb-47b1-bbf6-3b9e633cb8ff}" "D:\Backup\EventnikiceLinux\TEST_BACKUP" /E /MOVE
Done!
I have run your commands and they all worked. For extra I have also run this command: ROBOCOPY "D:\ServerVM\EventnikiceLinux." "D:\Backup." /E
And it started copying into "D:\Backup" folder.
I then modified your script with following parameters: "%_VBBACKUP%" --backupdir "D:\Backup." --backupmode acpipowerbutton --prefix "Daily Backup" --keep 7
However this resulted in same issue that we had until now (No destination directory).
Eureka... I managed to get this thing running. I have manually copied text from this file: https://github.com/niro1987/VirtualBox-Backup/blob/master/VirtualBox%20Backup.bat And it started working... I do not know what you have changed, however it resolved the issue.
Thank you so much for your effort. I hope I did not wast too much of your time?
Ooh man, great to hear. I wasn’t sure we were going to resolve this one.
Hi, I am trying to run your script for first time, so It may be that issue lies with how I am using it. However since I would really need this to work, I am contacting you in order to get some help.
This is basic information about my setup: VirtualBox is installed in standard location ("C:\Program Files\Oracle\VirtualBox") 7zip is also installed in standard location ("C:\Program Files\7-Zip"). All this is running on Windows 10 Pro OS.
My VM is located in folder "D:\Server VM\Eventnikice - Linux" and I want to create an backup in folder "D:\Backup".
Files from your script are located in "D:\Server VM\VirtualBox-Backup-master".
I have created script "Start Backup" with following content:
When I start script with double-click, it just flashes and shows CMD window for less than a second, but it does nothing else. Can you help me? If you need additional information, please let me know.
Thank you.