I was looking to create a regular backup of the KBOX appliance. Unfortunately, the KBOX itself will only go as far as backing up the data on the KBOX itself, and it is up to you, to grab them and place them on your backup media.

As I start all my research, I googled the backup process, and found a KB article to back up the KBOX. Unfortunately, I ran into some hurdles , and couldn’t get it to work on Windows 2008 Server R2. So I decided to re-write it in a way that would not require multiple files, and almost no configuration.

Before I put the steps down for my method, here is the issue that I had with the old script. If you have any ideas on fixing this, to make the KB article work, then, please share in the comments.

  • The backup.scr which contained the commands would not execute correctly when I ran it from the batch file. instead, it would take all the ftp commands, and echo them without line breaks, thus breaking the script.  It’s worth noting that i was running this on Windows 2008 R2, so there may be something that functions differently with the native ftp command.

As far as connectivity with the KBOX, if you are using Windows 2008 server, and your firewall is turned on, you are going to have to open up high ports in order to allow the get command, and directory listings to work. I believe this is an issue with passive FTP, which I’m not entirely sure if it can be actively controlled within the built-in FTP CLI. I essentially just opened up ports 20000-655535 to my KBOX only, and that resolved the problem. This is what the rule looks like.

netsh advfirewall firewall show rule name="Incoming From KBOX"

Rule Name:                            Incoming from KBOX
Description:                          To allow FTP downloads from KBOX
Enabled:                              Yes
Direction:                            In
Profiles:                             Domain,Private,Public
LocalIP:                              Any
RemoteIP:                            /32
Protocol:                             TCP
LocalPort:                            20000-65535
RemotePort:                           Any
Edge traversal:                       No
InterfaceTypes:                       Any
Security:                             NotRequired
Rule source:                          Local Setting
Action:                               Allow

You can either add this rule from the firewall GUI, or you can use this command line to add it:

netsh advfirewall firewall add rule name="Incoming from KBOX"
protocol=TCP dir=in localport=20000-65535 RemoteIP=/32 action=allow
description="To Allow FTP downloads from KBOX"

Make sure to replace the KBOX IP with the actual IP.

Now that the firewall is out of the way. Here’s how to setup the backup for your KBOX.

  1. On the server on which you want to house your backups, create a folder for the KBOX backups. i.e: K1000
  2. Copy and paste the code of this batch file into notepad, and save it as: DBBackup.bat
@echo off
set scrptloc="D:\Backups\K1000"
cd %scrptloc%
for /F "usebackq tokens=2-4 delims=^/ " %%p in (`date /t`) do mkdir %scrptloc%\%%r%%p%%q
for /F "usebackq tokens=2-4 delims=^/ " %%p in (`date /t`) do cd %scrptloc%\%%r%%p%%q
echo backing up to %scrptloc%
setLocal EnableDelayedExpansion
> %CD%\#.ftp echo open kbox
>> %CD%\#.ftp echo kbftp
>> %CD%\#.ftp echo getbxf
>> %CD%\#.ftp echo prompt
>> %CD%\#.ftp echo type binary
>> %CD%\#.ftp echo mget kbox_*
>> %CD%\#.ftp echo close
>> %CD%\#.ftp echo quit
"%systemroot%\system32\ftp.exe" -s:%CD%\#.ftp
del %CD%\#.ftp
goto end
cd "%scrptloc%"
@echo on

You can download the batch file HERE

At this point, your batch file should create a folder with the current date, and place the KBOX back up in it. Note that this script will just keep adding backups. So, make sure you have enough disk space for it, or write another script that would truncate those folders that are older than a certain date. Perhaps in a future article, I will share such a script.

At this point, the only item that is still required is to create a scheduled task for the script to run nightly, or as often as you like.

Here’s a screenshot of the schedule task:

If all went well, your backups should reside in the directory that you specified, in separate folders according to the date.

Print Friendly
Subscribe By Email for Updates.