Outlook backup

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
sourbread
Posts: 23
Joined: 26 Apr 2012 09:10

Outlook backup

#1 Post by sourbread » 26 Apr 2012 09:40

Hey guys, New to the forums and kinda new with batch in general. Here is my dilemma. I have to first search a computer to see if a .pst file exists, if it does (even if multiples exist) then I need to copy them from one drive to another.

Maybe I'm going about it wrong, but what I'm doing is:
1.) dir /b /s *.pst (to get the output of the directory)
2.) I want to now cd into the directory where they exist and
3.) xcopy from their currentl location to a shared drive (H:\)

I'm missing the bridge connecting 1 to 2 and that's where I was hoping where you guys could help

@echo off

cd\
dir /b /s *.pst

xcopy C:\filepath H:\Outlook_Backup /v /e /k /h /d /y /i

Any suggestions on the essential piece I'm missing?

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Outlook backup

#2 Post by foxidrive » 26 Apr 2012 10:04

Untested:

Code: Select all

@echo off
for /f "delims=" %%a in ('dir c:\*.pst /b /s /a-d ') do (
xcopy "%%a" "H:\Outlook_Backup" /v /e /k /h /d /y /i
)


If the files are in use then you could get errors.

sourbread
Posts: 23
Joined: 26 Apr 2012 09:10

Re: Outlook backup

#3 Post by sourbread » 26 Apr 2012 11:48

That did it! I'm using pskill to kill any open outlook sessions and the restarting Outlook at the end of the script. Thanks a million! I still have so much to learn but I'm really enjoying it!

frankadams
Posts: 1
Joined: 10 Oct 2012 12:53

Re: Outlook backup

#4 Post by frankadams » 10 Oct 2012 12:58

You may Backup and Recover outlook data due to http://www.recoverytoolbox.com/repair_outlook.html

Software works with corrupted .pst up to 32TB

Dos_Probie
Posts: 233
Joined: 21 Nov 2010 08:07
Location: At My Computer

Re: Outlook backup

#5 Post by Dos_Probie » 10 Oct 2012 18:35

If you have your batch working and dont want to display any output you can add the following nul command.

Code: Select all

@echo off
for /f "delims=" %%a in ('dir c:\*.pst /b /s /a-d 2^>nul') do (
xcopy "%%a" "H:\Outlook_Backup" /vekhdyi
)

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Outlook backup

#6 Post by foxidrive » 10 Oct 2012 18:46

sourbread wrote:That did it! I'm using pskill to kill any open outlook sessions and the restarting Outlook at the end of the script.


This was from April so is quite an old thread -

but be aware that killing Outlook with pskill or taskkill can damage the Outlook databases.

You would be better off using a different method of closing Outlook, such as send keys or perhaps Autoit to close Outlook gracefully.

Post Reply