Solved

Automatic Backup of Outlook connected to Exchange Server

Posted on 2008-10-13
5
544 Views
Last Modified: 2012-05-05
We need to backup Outlook automatically, every day.

Here are the circumstances:
Outlook 2007
Connected over Internet to Exchange Server.

There isn't a  .pst file.  There's an .ost file. My understanding of the  .ost  file is that it isn't the same as a .pst.  I don't know if backing up a copy of the .ost will help when there's damage to Outlook information.

Unless this is otherwise, I would like to have a complete export of the mailbox to a  local  .pst done every night automatically.  I am unsure of the scriptability of Outlook 2007.

Is there any software that would reliably do this?  The host makes a backup of the Exchange Server every night, but they want too much $$$ to perform a recovery.  If we had a local copy, we wouldn't have to get into an argument with them should we need to restore.  WE just had an incident where messages disappeared, and the host blamed us, and the rep asked if we 'had any proof' that they were responsible for the missing files.  

Thanks.

Larry
0
Comment
Question by:computerlarry
5 Comments
 
LVL 97

Assisted Solution

by:war1
war1 earned 50 total points
ID: 22703321
Hello computerlarry,

Backing up the OST file will back up what is on the Exchange.  You will need Exchange server and Outlook to open OST file.  For PST file, you only need Outlook to open the file. (You can convert OST file to PST file, but will involve some cost.)

Hope this helps!
war1
0
 
LVL 76

Expert Comment

by:David Lee
ID: 22703715
Hi, computerlarry.

Outlook is very scriptable and copying everything to a PST file is pretty simple.  Running it at night though is a bit of a problem.  Outlook has to be running under the account that owns the mailbox for a script to work.  That means everyone would have to leave their computer logged in at night for the backup to run.  The workstation could be locked, but it would have to stay logged in.  Another approach would be to schedule the backup to run during the day.  I can provide the script if you want to go this route.  The script will have to be added to each computer.
0
 

Author Comment

by:computerlarry
ID: 22814961
BlueDF - could I please have that script?

Thanks.
0
 
LVL 76

Accepted Solution

by:
David Lee earned 450 total points
ID: 22820292
Sure.  Here it is.  Follow these instructions to use it.

1.  Start Outlook
2.  Click Tools->Macro->Visual Basic Editor
3.  If not already expanded, expand Microsoft Office Outlook Objects and click on Module1
4.  Copy the code from the Code Snippet box and paste it into the right-hand pane of Outlook's VB Editor window
5.  Edit the code as needed.  I included comments wherever something needs to or can change
6.  Click the diskette icon on the toolbar to save the changes
7.  Close the VB Editor
8.  Click Tools > Trust Center
9.  Select Macro Security
10.  Ensure the security setting is one of the bottom two options
11.  Close Outlook
12.  Start Outlook

Run the macro whenever you want to backup the mailbox.
Sub BackupMailboxToPSTFile()

    'Change the path on the following line to your path

    Const BACKUP_PATH = "C:\eeTesting\Backups\"

    Dim strBackupFileName As String, _

        objFSO As Object, _

        olkRootFolder As Outlook.MAPIFolder, _

        olkFolder As Outlook.MAPIFolder, _

        olkFolderCopy As Outlook.MAPIFolder, _

        olkBackup As Outlook.MAPIFolder

    strBackupFileName = "BU " & Format(Time, "hhmm") & "_" & Format(Date, "dd mmm yyyy") & ".pst"

    Set objFSO = CreateObject("Scripting.FileSystemObject")

    If objFSO.FileExists(BACKUP_PATH & strBackupFileName) Then

        MsgBox "The mailbox was already backed up within the last minute.", vbInformation + vbOKOnly, "Folder BackUp"

    Else

        Session.AddStore BACKUP_PATH & strBackupFileName

        Set olkBackup = OpenOutlookFolder("Personal Folders")

        olkBackup.Name = strBackupFileName

        Session.RemoveStore olkBackup

        Session.AddStore BACKUP_PATH & strBackupFileName

        Set olkBackup = OpenOutlookFolder(strBackupFileName)

        Set olkRootFolder = Session.GetDefaultFolder(olFolderInbox).Parent

        For Each olkFolder In olkRootFolder.Folders

            Set olkFolderCopy = olkFolder.CopyTo(olkBackup)

        Next

        Session.RemoveStore olkBackup

    End If

    Set objFSO = Nothing

    Set olkBackup = Nothing

    Set olkRootFolder = Nothing

    Set olkFolder = Nothing

    Set olkFolderCopy = Nothing

    MsgBox "Backup complete.", vbInformation + vbOKOnly, "Backup Mailbox to PST"

End Sub
 

Function IsNothing(obj)

  If TypeName(obj) = "Nothing" Then

    IsNothing = True

  Else

    IsNothing = False

  End If

End Function
 

Function OpenOutlookFolder(strFolderPath As String) As Outlook.MAPIFolder

    Dim arrFolders As Variant, _

        varFolder As Variant, _

        olkFolder As Outlook.MAPIFolder

    On Error GoTo ehOpenOutlookFolder

    If strFolderPath = "" Then

        Set OpenOutlookFolder = Nothing

    Else

        If Left(strFolderPath, 1) = "\" Then

            strFolderPath = Right(strFolderPath, Len(strFolderPath) - 1)

        End If

        arrFolders = Split(strFolderPath, "\")

        For Each varFolder In arrFolders

            If IsNothing(olkFolder) Then

                Set olkFolder = Session.Folders(varFolder)

            Else

                Set olkFolder = olkFolder.Folders(varFolder)

            End If

        Next

        Set OpenOutlookFolder = olkFolder

    End If

    On Error GoTo 0

    Exit Function

ehOpenOutlookFolder:

    Set OpenOutlookFolder = Nothing

    On Error GoTo 0

End Function

Open in new window

0
 

Expert Comment

by:VicManuel
ID: 24175693
As would be code to copy all the *. pst? incremental *.pst
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
MS Word Office 365 Mail Merge 2 48
Outlook Calendar Permissions 4 39
exchange, outlook 7 38
Outlook importing calendar entries 6 58
Outlook Free & Paid Tools
Find out what you should include to make the best professional email signature for your organization.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now