Skip to content

Instantly share code, notes, and snippets.

@mchangrh
Last active February 18, 2023 02:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mchangrh/632ac4a3eeae124c7b47f5de7dce743d to your computer and use it in GitHub Desktop.
Save mchangrh/632ac4a3eeae124c7b47f5de7dce743d to your computer and use it in GitHub Desktop.
Office 365 Backup Solution

Office 365 Backup Solution

tl;dr "Buy Office 365 Cloud - Cloud Backup" - So I created my own alternative I received a phone call from another business who tried to sell me on a Office 365 Cloud - Cloud Backup solution. I work at a relatively small company so our email is managed on Office 365. I havn't heard of any Office 365 Backup Solutions so I played along and tried to get the details out. Unfortunately, after a quick Google search, there were only paid, enterprise solutions and nothing open source. So here's the workaround.

Setup

To set this system up, a few components are required

Outlook Configuration

!! DISCLAIMER

You will have to download your entire Outlook Database. Make sure you have the bandwidth and time to leave it running. (Overnight works too)

  1. Navigate to File
  2. Go to the Info tab and click on Account Settings
  3. Click on the E-mail tab and make sure your account is selected. Click on the change button
  4. Under Offline Settings, Enable Cached Exchange Mode and move the slider "Mail to keep offline" to All.
  5. Go to the Data Files Tab and you should see the location of the Offline cache.

Backup Configuration

Point your backup solution at %LocalAppData%/Microsoft/Outlook/*.ost

Borg With WSL Configuration

borg create \
    /path/to/repo::'{hostname}-{now}'       \
    -- verbose                              \
    -- stats                                \
    /mnt/c/users/$username/AppData/Local/Microsoft/Outlook/

VSS Shadow Copy

  1. Mount your VSS Shadow with mklink.
  • mklink /D /C:\ShadowVolume \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy1\
  • To unmount the VSS Shadow - cmd: rmdir C:\ShadowVolume - PowerShell: cmd /c rmdir C:\ShadowVolume
  1. Copy the folder however you would like, just append C:\ShadowVolume to the path
  • copy C:\ShadowVolume\%LocalAppData%/Microsoft/Outlook/{email@domain.com}.ost C:\Backups\Outlook\{email@domain.com}_%d-%m-%Y.ost

Restic on Windows

SET AWS_ACCESS_KEY=awsaccesskey
SET AWS_SECRET_ACCESS_KEY=mysupersecretaccesskey
SET RESTIC_PASSWORD=supersecurebackupkey

restic -r s3:https://repository.domain.tld/restic backup c:/users/$username/AppData/Local/Microsoft/Outlook
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment