Backup Outlook with Batch commands

by

OK I know I’m going to use this over and over so here’s the beef;

First you need to create a wait batch file so you can give the user some time to log off Outlook before you kill it. In Windows XP there is no wait command unless you install the resource kit and to be honest it’s quicker to create a batch file that will do the same thing. This is that batch file…

@ping 127.0.0.1 -n 2 -w 1000 > nul
@ping 127.0.0.1 -n %1% -w 1000> nul

Save that as a batch file called something like wait.bat.

Second thing  you need to do is create the actual backup batch file. Something like this;

@echo off
Echo “Shutting down Outlook in 30 seconds!!!”
Echo “Please Close outlook NOW!!!”
call wait 30
taskkill /im outlook.exe
rmdir /s /q m:\backup
mkdir m:\backup
mkdir “m:\backup\outlook”
xcopy “C:\Documents and Settings\username\Local Settings\Application Data\Microsoft\Outlook\*.*” “m:\backup\outlook\*.*” /s /e /c
xcopy “C:\Documents and Settings\username\Application Data\Microsoft\Outlook\*.nk2” “m:\backup\outlook\” /s /e /c

Obviously change username for the real path.

There is a risk when you kill Outlook but as long as it’s not doing anything at the time it should be OK. Worst case is that it will force an intergrity check when you start up outlook again.

My reason for killing Outlook is that if you don’t kill it, then it will simply not backup. Assuming you added ShadowCopy to your network server’s shared drive then you’ll have multiple copies in that location even though you delete it and recreate it each time with this batch file.

Kudos to Malektips.com for the wait command!

Advertisements

Tags: , , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: