• Outlook User
  • New Outlook app
  • Outlook.com
  • Outlook Mac
  • Outlook & iCloud
  • Developer
  • Microsoft 365 Admin
    • Common Problems
    • Microsoft 365
    • Outlook BCM
    • Utilities & Addins

Backup Outlook Data Files using a Batch (.bat)

Slipstick Systems

› Outlook › Configure and Maintain › Backup Outlook Data Files using a Batch (.bat)

Last reviewed on February 10, 2022     4 Comments

This is really old school, from back in the days of DOS and Win3.1, but it still works great with Outlook and Windows 7. Copy a code block to notepad and save using the file extension .bat. Double click to run it. You can add it to the Startup folder if desired.

If you prefer to use PowerShell, I have sample scripts at Use PowerShell to backup Outlook PST files.

Use this instead of the Backup utility provided by Microsoft (which does not work with 64-bit Outlook).

Note: If your path doesn't include spaces, you don't need to use double quotes.

For more information about the copy and xcopy commands and the switches you can use with them, see COPY, XCOPY, and MOVE Overwrite Functionality Changes in Windows (MSKB article)

Copy the pst file to a new location (overwrite existing file), when the copy is finished, start Outlook.

The /y switch overwrites the existing file, if it exists. Wait tells the batch to stop until the copy is finished before starting outlook.

copy /y "C:\path\to\original\datafile.pst" "C:\path\to\Backup\datafile.pst"
:wait
start outlook.exe

Copy the data file and give it a random name; when the copy is finished, start Outlook:

%random% replaces the file name with a random number to prevent files from being overwritten. Use the date stamp to identify the age of the files.

copy "C:\path\to\original\datafile.pst" "C:\path\to\Backup\"%random%.pst
:wait
start outlook.exe

Copy the pst file and rename it using today's date, start Outlook when the copy is complete.

This gets the date and breaks it down into year, month, day format, which we use in the filename of the copy. The batch waits for the copy to finish before starting Outlook.

for /f "tokens=1-5 delims=/ " %%d in ("%date%") do copy "C:\path\to\outlook.pst" "C:\path\to\Backup\"backup-%%g-%%e-%%f.pst
:wait
start outlook.exe

Copy all pst files in the folder, add the date to their file name. Start Outlook when the copy is finished.

This copies all of the pst files in the folder and like the previous batch file, this one adds the date to the filename of the copied pst files.

for /f "tokens=1-5 delims=/ " %%d in ("%date%") do copy "C:\Users\dianep\Documents\Outlook Files\"*.pst "C:\Users\dianep\Documents\Outlook Files\Backup\"*-%%g-%%e-%%f.pst
:wait
start outlook.exe

Copy other Outlook support files using a batch file

You can use a batch file to copy other files Outlook uses, including templates, signatures, and stationery. You can use the same methods used to copy the pst files, however, if you want to copy subfolders within a folder path, you'll need to use XCOPY instead of COPY.

Because the support files change less often, you can run this batch file weekly or after you make changes (such as editing your signature.)

To copy folders within a path, you'll need to use XCOPY and the /y and /e switches:

xcopy /y /e "C:\Users\username\AppData\Roaming\Microsoft\Templates\*.*" "C:\Backup\Templates\"
xcopy /y /e "C:\Users\username\AppData\Roaming\Microsoft\Stationery\*.*" "C:\Backup\Stationery\"
xcopy /y /e "C:\Users\username\AppData\Roaming\Microsoft\Signatures" "C:\Backup\Signatures"

More Information

For third party backup utilities, see the Tools lists on the following pages:
Outlook 2010 Backup and Dual-Boot File Locations
Outlook 2007 Backup and Dual-Boot File Locations
How to Backup your Outlook Account Settings

Backup Outlook Data Files using a Batch (.bat) was last modified: February 10th, 2022 by Diane Poremsky

Related Posts:

  • Use PowerShell to backup Outlook PST files
  • Moving Outlook .pst files to a new computer
  • Using OneDrive or Cloud Storage for PST Files
  • How to Backup your Outlook Account Settings

About Diane Poremsky

A Microsoft Outlook Most Valuable Professional (MVP) since 1999, Diane is the author of several books, including Outlook 2013 Absolute Beginners Book. She also created video training CDs and online training classes for Microsoft Outlook. You can find her helping people online in Outlook Forums as well as in the Microsoft Answers and TechNet forums.

Subscribe
Notify of
4 Comments
newest
oldest most voted
Inline Feedbacks
View all comments

Rainer Richard Friedrich (@guest_183095)
April 23, 2014 1:49 am
#183095

Looks fine. Tipp: Use %USERPROFILE% in the batch, so it is not dependant on fixed usernames.

1
0
Reply
Thomas Hoopes (@guest_175044)
March 22, 2013 10:52 am
#175044

Any way to adjust this script to hit a list of computers, and grab a 'username' variable to put into the backup file name?

0
0
Reply
Diane Poremsky (@guest_175052)
Reply to  Thomas Hoopes
March 22, 2013 3:01 pm
#175052

I think so, but I don't have any code samples that do this. You may need wmic to get the user names then can pipe them into the batch.
General information pages on batch files:
https://support.microsoft.com/kb/240268
https://www.sevenforums.com/performance-maintenance/23820-batch-file-copy-made-easy.html

0
0
Reply
Christoffer Jonsson (@guest_185035)
Reply to  Thomas Hoopes
August 6, 2014 12:41 pm
#185035

xcopy /y /e "C:\Users\username\AppData\Roaming\Microsoft\Templates\*.*" "C:\Backup\Templates\"
xcopy /y /e "C:\Users\username\AppData\Roaming\Microsoft\Stationery\*.*" "C:\Backup\Stationery\"
xcopy /y /e "C:\Users\username\AppData\Roaming\Microsoft\Signatures" "C:\Backup\Signatures"

Not tested but this should work, so you can use it with GPO for example:
xcopy /y /e "%appdata%\Microsoft\Templates\*.*" "C:\Backup\Templates\"
xcopy /y /e "%appdata%\Microsoft\Stationery\*.*" "C:\Backup\Stationery\"
xcopy /y /e "%appdata%\Microsoft\Signatures" "C:\Backup\Signatures"

2
0
Reply

Visit Slipstick Forums.
What's New at Slipstick.com

Latest EMO: Vol. 30 Issue 15

Subscribe to Exchange Messaging Outlook






Support Services

Do you need help setting up Outlook, moving your email to a new computer, migrating or configuring Office 365, or just need some one-on-one assistance?

Our Sponsors

CompanionLink
ReliefJet
  • Popular
  • Latest
  • Week Month All
  • Use Classic Outlook, not New Outlook
  • How to Remove the Primary Account from Outlook
  • Disable "Always ask before opening" Dialog
  • Adjusting Outlook's Zoom Setting in Email
  • This operation has been cancelled due to restrictions
  • Remove a password from an Outlook *.pst File
  • Reset the New Outlook Profile
  • Maximum number of Exchange accounts in an Outlook profile
  • Save Attachments to the Hard Drive
  • How to Hide or Delete Outlook's Default Folders
  • Google Workspace and Outlook with POP Mail
  • Import EML Files into New Outlook
  • Opening PST files in New Outlook
  • New Outlook: Show To, CC, BCC in Replies
  • Insert Word Document into Email using VBA
  • Delete Empty Folders using PowerShell
  • Warn Before Deleting a Contact
  • Classic Outlook is NOT Going Away in 2026
  • Use PowerShell to Delete Attachments
  • Remove RE:, FWD:, and Other Prefixes from Subject Line
Ajax spinner

Recent Bugs List

Microsoft keeps a running list of issues affecting recently released updates at Fixes or workarounds for recent issues in classic Outlook (Windows).

For new Outlook for Windows: Fixes or workarounds for recent issues in new Outlook for Windows .

Outlook for Mac Recent issues: Fixes or workarounds for recent issues in Outlook for Mac

Outlook.com Recent issues: Fixes or workarounds for recent issues on Outlook.com

Office Update History

Update history for supported Office versions is at Update history for Office

Outlook Suggestions and Feedback

Outlook Feedback covers Outlook as an email client, including Outlook Android, iOS, Mac, and Windows clients, as well as the browser extension (PWA) and Outlook on the web.

Outlook (new) Feedback. Use this for feedback and suggestions for Outlook (new).

Use Outlook.com Feedback for suggestions or feedback about Outlook.com accounts.

Other Microsoft 365 applications and services




New Outlook Articles

Google Workspace and Outlook with POP Mail

Import EML Files into New Outlook

Opening PST files in New Outlook

New Outlook: Show To, CC, BCC in Replies

Insert Word Document into Email using VBA

Delete Empty Folders using PowerShell

Warn Before Deleting a Contact

Classic Outlook is NOT Going Away in 2026

Use PowerShell to Delete Attachments

Remove RE:, FWD:, and Other Prefixes from Subject Line

Newest Code Samples

Insert Word Document into Email using VBA

Warn Before Deleting a Contact

Use PowerShell to Delete Attachments

Remove RE:, FWD:, and Other Prefixes from Subject Line

Change the Mailing Address Using PowerShell

Categorize @Mentioned Messages

Send an Email When You Open Outlook

Delete Old Calendar Events using VBA

Use PowerShell or VBA to get Outlook folder creation date

Rename Outlook Attachments

Repair PST

Convert an OST to PST

Repair damaged PST file

Repair large PST File

Remove password from PST

Merge Two Data Files

Sync & Share Outlook Data

  • Share Calendar & Contacts
  • Synchronize two computers
  • Sync Calendar and Contacts Using Outlook.com
  • Sync Outlook & Android Devices
  • Sync Google Calendar with Outlook
  • Access Folders in Other Users Mailboxes

Diane Poremsky [Outlook MVP]

Make a donation

Mail Tools

Sending and Retrieval Tools

Mass Mail Tools

Compose Tools

Duplicate Remover Tools

Mail Tools for Outlook

Online Services

Calendar Tools

Schedule Management

Calendar Printing Tools

Calendar Reminder Tools

Calendar Dates & Data

Time and Billing Tools

Meeting Productivity Tools

Duplicate Remover Tools

Productivity

Productivity Tools

Automatic Message Processing Tools

Special Function Automatic Processing Tools

Housekeeping and Message Management

Task Tools

Project and Business Management Tools

Choosing the Folder to Save a Sent Message In

Run Rules on messages after reading

Help & Suggestions

Submit Outlook Feature Requests

Slipstick Support Services

Buy Microsoft 365 Office Software and Services

Visit Slipstick Forums.

What's New at Slipstick.com

Home | Outlook User | Exchange Administrator | Office 365 | Outlook.com | Outlook Developer
Outlook for Mac | Common Problems | Utilities & Addins | Tutorials
Outlook & iCloud Issues | Outlook Apps
EMO Archives | About Slipstick | Slipstick Forums
Submit New or Updated Outlook and Exchange Server Utilities

Send comments using our Feedback page
Copyright © 2025 Slipstick Systems. All rights reserved.
Slipstick Systems is not affiliated with Microsoft Corporation.

wpDiscuz

Sign up for Exchange Messaging Outlook

Our weekly Outlook & Exchange newsletter (bi-weekly during the summer)






Please note: If you subscribed to Exchange Messaging Outlook before August 2019, please re-subscribe.

Never see this message again.

You are going to send email to

Move Comment