Blog Navigation
Partners
Latest Activity
Phil gives the source code for implementing a MySQL singleton class in both PHP and Python.
Win Serv 2003 Backups over a network w/out being logged in
As you probably know by now, I have a Microsoft Exchange 2007 server. With any kind of server, a backup and disaster recovery plan is a vital part of any kind of professional hosting. Hosting email can be quite tricky as it is, but taking network backups was a new road that I’ve never covered in Windows.
First, I have a fairly simple environment set up for my backup. I have a Linux backup server running samba sitting in Seattle (mthsweb2). This server has the Windows IP white listed so that only my Windows server can connect to it to map a network share. For those of you who don’t know what samba is, samba is a daemon in Linux that will allow Windows to naively connect to a Linux server for file sharing. Samba is a very simple solution for mapping a network drive to Linux in Windows without needing any specialized software such as sftpdrive (not called something else).
I want to connect Windows to Linux so I mapped a network drive on the Windows server (and I made sure reconnect at login was checked). I logged in using the proper credentials and saved them to my Windows user account. I then proceeded to setup NTBackup (the Windows server backup utility). Configuring NTBackup was quite simple, a few next’s and a couple of checks on my exchange server information, system state, and a few very important directories that hold onto ssl certificates for the server. Naturally, the backup ran fine while I was logged in. The problem was, when I was logged off the server, the backup failed because the network drive wasn’t there.
After some research, I found an easy way to solve this via batch scripting. I could schedule a task in Windows that would run the batch script which would map the network drive for my system and execute NTBackup. Below is the script (you will need to customize the bold parts as described below):
—————————————————–
@echo off
net use z: serverbackup /persistent:yes
C:WINDOWSsystem32ntbackup.exe backup “@C:Documents and SettingsadminLocal SettingsApplication DataMicrosoftWindows NTNTBackupdatad.bks” /a /d “Set created 7/10/2009 at 1:49 PM” /v:no /r:no /rs:no /hc:off /m normal /j “d” /l:s /f “C:Documents and SettingsadminMy DocumentsBackup.bkf”
net use z: /d /y
exit
———————————————————
Now that we have a script, what do we put in place of the bold remarks? Server should be the IP Address of your remote file server. This can either be a Linux server running samba or a Windows File Server. Either method will require that you open up a range of file sharing ports on your firewall, I tend to just whitelist the ip of the server doing the backup from the backup server’s firewall. If you are curious of the ports, I believe you need TCP ports 135-139 open for Windows file sharing to work, but there may be more. The bolded backup is the path from the file sharing server to where you want to store your backup.
To get the other bolded part, you will need to login to Windows and map a network drive under the letter you used in the script (Z in this case). Once the drive is mapped, make sure you save your login credidentials. Now goto the system backup utility in start>programs>accessories>system. Select your desired backup files and when you get to the location selection screen, make sure you save to the network drive letter you created. Then when you get to the finish screen, click advanced. Do a normal backup appending to existing backups (or whatever you desire). Schedule the job for later (try a few days or a week later). You will need to type in your username / password up to 4 times until you get past this screen to the finish screen. Once done configuring your backup, goto start>programs>accessories>system -> scheduled tasks. Double click the backup you made and you should see something like the blurb in the batch script above. You will need to copy this entire line and paste it into this batch script. After you have this line successfully saved into your script, you should disconnect the drive letter from my computer by right clicking the drive and selecting disconnect.
Now take the entire composed batch script and paste it into a new notepad document. Now goto file > save as on notepad and save it to a file like backup.bat in the c drive or someplace where it will be easily findable.
Now you can go back to the scheduled tasks, remove that backup job (its not needed anymore) and remove it from the recycle bin. Now create a new scheduled task. This time select the bat script you made and schedule it as needed. Its a fairly simple set of on screen instructions to follow. Once this task is scheduled you’re all set.
If you wish to test the batch script before making it a scheduled task, simply click on it and your backup should run perfectly.
Thats all there is to it. This was a 5 minute fix for me and I no longer have to worry about finding a third party solution to making stable backups of my operating system. In addition to this backup method, you might want to look into running a mirror where 2 drives copy each other live. This will also prevent against data loss provided there isn’t any danger in the server room such as fire or water damage.
Tags: backup, batch, Linux, mapped network drive, network, ntbackup, samba, script, server 2003, windows
Posted in Hosting / Server Administration
Great idea, but will this work over the long run?
Yes it will. I’ve been using it for a while now
I can’t tip because I didn’t like