Microsoft removed the Outlook PST backup tool, but that won't stop you from automatically backing up your PST files. You can use Batch (.bat) files or PowerShell to make a copy of your PST files. Create a scheduled task to run the backups or (Outlook needs to be closed to backup PST files open in Outlook.)
Batch file scripts are at Backup Outlook Data Files using a Batch (.bat)
While you can make copies of OST files used by IMAP and Exchange accounts, because an OST is just an offline cache of the mailbox on the server, everything in the OST file is synced. One glaring exception: if you use an IMAP account and have Calendar, Contacts, and Tasks folders with "this computer only" in the name, they are not synced with the server. But, because OST files can only be opened by the account and profile that created the OST file, you need a 3rd party utility to recover content in the OST file if the account was removed from your profile. Instead, you should export the calendar and contacts to a CSV or PST file.
To copy all the PST file in a specific location, to a backup folder in another location:
Copy-Item "C:\Outlook Files\*.pst" "D:\PST Backups"
This script will work on any computer when you use the default location for the PST files (C:\Users\%username%\Documents\Outlook Files).
Copy-Item $Env:USERPROFILE"\Documents\Outlook Files\*.pst" "D:\PST Backups"
Create a subfolder with today's date for the backup location. Storing PST files in folders by date reduces clutter if you have multiple PST files and makes it easy to delete old backup sets.
$TodayFolder = "D:\PST Backups\$(get-date -f yyyy-MM-dd)" New-Item $TodayFolder -ItemType Directory Copy-Item $Env:USERPROFILE"\Documents\Outlook Files\*.pst" $TodayFolder
Close Outlook, copy the PST files then reopen it after the PST files are copied.
Get-Process Outlook | Foreach-Object { $_.CloseMainWindow() | Out-Null } | stop-process âforce $TodayFolder = "D:\PST Backups\$(get-date -f yyyy-MM-dd)" New-Item $TodayFolder -ItemType Directory Copy-Item "D:\Documents\Outlook Files\*.pst" $TodayFolder Start-Process -FilePath "Outlook"
Copy the pst file only if it has changed
If you only want to make a copy of the pst file if it has changed, this PowerShell script compares the file size, copying it only if the file size is different. You can look for different sizes (if you delete mail or compacted the original pst) or only copy the file if the original is larger.
$Archive = Get-Item "C:\Users\diane\Documents\Outlook Files\Archive.pst" $BackUp = Get-Item "C:\Users\diane\Documents\Archives\Archive.pst" write-host "Archive size" ((Get-Item $Archive).length/1KB) write-host "Backup size" ((Get-Item $BackUp).length/1KB) #size different #if ($Archive.Length -ne $Backup.Length) #is larger if ($Archive.Length -gt $Backup.Length) { "files are different" Copy-Item $Archive $BackUp write-host "Copied!" }
How to use PowerShell
Type PowerShell on the start menu. For editing and testing PowerShell scripts, open Windows PowerShell ISE.
If you don't have the white editor section at the top, click the Show Script Pane button.
Paste the PowerShell script in the window, edit it as needed then click the Run button. Errors (if any) will be in the bottom.
Run using Task Scheduler
If you want to automate running the PowerShell, save the script with a .ps1 extension.
If this is the first time you've run a PowerShell script, you will likely receive an error "File C:\path\to\backup-pst.ps1 cannot be loaded because running scripts is disabled on this system."
To change the execution policy in PowerShell start PowerShell in administrator mode and run this command. Enter Y to allow it to change the policy.
Set-ExecutionPolicy RemoteSigned
- Open Task Scheduler
- Choose Create Basic Task
- Step through the wizard, selecting how often you want it to ruin and at what time. (Choose a time when you are less likely to be working in Outlook.)
- On the Action page, choose Start a program.
- Type powershell.exe in the Program/script field.
- Type -file "C:\path\to\backup-pst.ps1" in the Add Arguments field. The Action will look like this:
- If you want the script to run even if you are not logged into your user account, open the newly created task, and choose Run whether users to logged on or not.
- To test your task, right click on it in the Task Schedule Library and choose Run.
- If it worked, the Last Run Result column will say it completed successfully and the pst files will be copied.