Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script to back up PST files from all computers to Server 2

Status
Not open for further replies.

bence8810

IS-IT--Management
Jul 20, 2005
241
AE
Dear Script Gurus,

Please note that I am a complete beginner with Scripting, I kind of dont even know what scripts are :) Having said that, I am in need to put all PST files from users' computers to a server which will be backed up as one.

I have a "script" (DOS batch file) which copies the PST file to the server upon boot (Using GPO and logon script). The problem is that while the PST file is being copied, the computer still boots up and shows the desktop, so the user can launch Outlook, and the Copy all of a sudden fails.

How would I go about a very simple script that wouldnt allow them to Open Outlook, or just to Note them not to open until it finishes. I basically need to run this script for every user once a week, maybe 7 users a day. We have 35 users.

The exchange server is exhausted with the amount of Email everyone has, so I needed to start archiving to local PST folders, but those are not backed up yet.

Thanks for any pointers, and I am open to new ideas of how to backup as well.

Thanks,

Ben
 
can you simply make your script which applies at logon run synchronosly?? or however you spell it. i mean that windows wont continue to load until the script has finished?
 
Hi

Yes, that is what I would like to do, but dont know how to... My script is very basic, it isnt even a script. This is how it looks, please dont laugh.

copy D:\Personal\Mail\*.pst \\bckupsrv1\PST-Backup\BFrank\

That is all, a one liner. Gets the job done, but I have to keep in mind not to start Outlook until it finishes. For a 2-3GB file, it might take about 5 minutes, and there is no warning when it is DONE, so I just have to guess when it is done to start outlook. For my users, I cannot give this as a solution. They need some note of completion, or simply not being able to do anything while it finishes, and then letting them to touch Windows.

Another thing would be I guess to make it a logoff script, so the user could just leave the machine there to finish off when they go home. However, I have heard that outlook doesnt always finish/quit smoothly, so the PST files are still not transferrable....

Thanks for any further points,

Ben
 
your script is fine, end of the day if it does the job and is simple then that is quality in my mind.,

i am sure you can set scripts to run async or sync via AD, not really my field i am afraid. it might be worth looking through some old posts in the W2k3 forum or doing a goggle on just that. markdmac should know

if not it wouldnt be too hard to script the prevention of outlook.exe from loading, well i say that but you might be left with some blocked method call which waits for new process WMI events and checks if it is outlook.exe and then kills it, this time lag might be enough to cause you issues.

hmm thinkin out loud i might be inclined to rename outlook.exe to outlook.old at the start of your copy job and then rename it afterwards!!! sounds ugly as sin, but what the heck its Friday, have a nice weekend
 
Hi MrMovie,

Like your ideas already :) renaming the Outlook.exe. I am sure that would solve the problem, but I would really like to let the users know what is happening, in case they shouldnt launch outlook.

Now what I have done is I set the same exact script to run at Log-Off. This works much better, I guess until the previously mentioned "Outlook not quitting smootly" scenarrio happens, and the whole backup will fail as the script sees the PST files as Open, so it will terminate running itself.

However, I tested this Logoff script on my PC, and it worked like a charm. Outlook did quit fine, and the PST files were transferrable. And in this case, when the small window pops up during the Logoff, it displayed "Running Logoff Scripts", which is nicely informative. BTW, May I alter that text somehow?

Now the only one remining issue, how to make this script run only at specific times? I would like it to run once a week, or even fewer times than that.

Thanks, and I will google further.

Ben
 
with the logoff script you should be in a position to do the following:

run a vbscript which does the following:

1. monitor the currently running processes WMI query Win32_Process
2. When it detects there is no\no longer outlook.exe running it can carry on with the copy pst file job?

or

1. script which checks the status of each file in the pst store to see if it is use??? loops until they arent in use anymore then does something??? (never tried this sort of query or manip myself/.)




with regards to running it only on certain occasions...

Select Case WeekDay(Now())

Case 1, 3, 5
'think this means it is a Sunday, Tuesday or Thursday
Call doWork()

End Select

Sub doWork()
'sub to do the WMI query or just call the batch job to copy files???



End Sub
 
there is a backup addin for outlook that you might want to consider looking at?
 
Hi

Wow, sounds all jibberish to me, and this is because I am not familiar with scripts. I guess I could read up on scripting a bit before I go ahead with this. But I am glad already that this might be possible to carry out.

So basically for a starter, until I am not familiar with Scripting, I could just use what you wrote above, and then have it run my Batch-file? And when I am more able as far as scripting goes, I can swap that batch-file for some more VB codes...

The Outlook backup I have looked at a long time ago, and still considering it. Thing is that it wont run in the backgound nicely, like a logoff-script would. I tried it just now, and it also needs to wait until outlook exits, and then will do a simple copy to somewhere. Of course this opens up a regular copy "window", which has a CANCEL button. I am not pessimistic, but I have seen/heard many things. Of course if that CANCEL button was pressed, the liable person for lost emails still remain to be me :)

Thanks for your posts, I will be off googling again, and for some of this weekend. Of course all comments are more than welcome. I am an idiot when it comes to advanced things like scripting :)

Cheers all, have a good weekend,

Ben
 
Hi

After googling for a while, this is where I am. Pretty immature still I know .... but I dont need to use the Batch -file anymore. I wrote a small VBS script, which does exactly the same as the BAT file I had.

This is how it looks.

Code:
ON Error Resume Next

Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile "D:\Personal\Mail\*.pst" , 

"\\bckupsrv1\PST-Backup\BFrank\"

I will try to advance it myself, but if you have any other options, please post. I am looking for having it run only on certain days, and for certain people only.

The easy but messy thing would be to create 5 GPO's for 7 people each, and have them run at different times somehow.

Thanks

Ben
 
have a look at

Select Case WeekDay(Now())

Case 1, 3, 5
'think this means it is a Sunday, Tuesday or Thursday
Case Else


End Select
 
Hi

Thanks. I am not at the office anymore, so until monday I cannot test, but would this be ok below? Would it mean that the script will only run on Monday at Logoff with the below code?

Thanks

Ben

Code:
ON Error Resume Next

Select Case WeekDay(Now())

   Case 2
   Case Else
       

End Select


Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile "D:\Personal\Mail\*.pst" , 

"\\bckupsrv1\PST-Backup\BFrank\"
 
'this is prob more like it
Select Case WeekDay(Now())

Case 2
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile "D:\Personal\Mail\*.pst" , "\\bckupsrv1\PST-Backup\BFrank\"
Set objFSO = Nothing
Case Else


End Select

'or
Select Case WeekDay(Now())
Case 2
Case Else
Wscript.Quit
End Select
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile "D:\Personal\Mail\*.pst" , "\\bckupsrv1\PST-Backup\BFrank\"
Set objFSO = Nothing

'i personally think exiting out of script half way through is bad style.
'to begin with i would avoid the use of On Error Resume Next

 
Hi

Thanks for that. Yes, I got you now. You can see how much I dont know about what I am talking about :)

I will try the script, and see if it will work or not, then post back.

thanks

Ben
 
'you might want to consider stuff like...

'this is prob more like it
Select Case WeekDay(Now())

Case 2
Set WshShell = CreateObject("Wscript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
strUserName = WshShell.ExpandEnvironmentStrings("%username%")
objFSO.CopyFile "D:\Personal\Mail\*.pst" , "\\bckupsrv1\PST-Backup\" & strUserName & "\"
Set objFSO = Nothing
Set WshShell = Nothing
Case Else


End Select
 
Hi

The script you posted two posts above works like a charm. I didnt try the one you just posted, but you are reading my mind. I was just about to post and ask how I could implement saving it to a Users directory automatically. I guess that is what the script will do now.

I am off testing, many thanks.

Ben
 
Hi

I tried it, and it runs like magic. It puts it to the user's folder with no problem.

Now I just need to make sure that PST files are on that folder. Is there a possibility to allow the Script to browse the file system for PST files, and copy them all? I might be asking for too much...

Thanks for your great help, I am already ahead of myself.

Ben
 
You are really spinning your wheels here, though it may be a good exercise for you to learn scripting. As MrMovie mentioned Microsoft has a utility to do this already.

Get the download here:

Learn how to use it here:

I hope you find this post helpful.

Regards,

Mark
 
thats one of the issues with FSO filecopies etc they tend not to be as useful as dos commands. PHV i am sure could point you in the right direction for a one line'r.

if you want to do it avoiding shelling out to dos commands then you could issue a WMI query for all File objects with .pst in the name. whilst i would applaud this method it would result in lots of code and would end up being pretty slow i think.

pragmatic approach would be a shell command, not my strong point i am afraid
 
Hi

Thanks guys. I will read that site, and try to use the tool and learn. I have gotten a lot of help here, and I appreciate it.

Cheers

Ben
 
Hi

The script works rather good, I already got some of the users emails. However, I stumbled upon another possible problem. Some users have more than 10GB worth of PST files. As I set the script so far, it will do the backup on Mondays. The problem is, that on monday, whenever the user restarts (logs off), the script will be run, and the PST files transfered. At 10GB, it takes about 30 minutes to copy them to the server. If the user has to reboot a few times, half of his/her day is gone.

Is there a way to implement in the script, that if it was run already once, it would be ignored?

Thanks
Ben
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top