David Hedges

  • Home
  • About
  • Contact
  • Business Blog
  • IT Blog

Backing up Microsoft Exchange to a samba share

January 12, 2021 by dhedges Leave a Comment

Backing up exchange by dumping mailboxes to .pst files can be done using the new-mailboxexportrequest command. This works best though when you script out the process. I have a powershell script I had written, and works for my case:

  Add-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn
 
 Get-MailboxExportRequest -Status Completed | Remove-MailboxExportRequest -Confirm:$false
  Get-MailboxExportRequest -Status failed | Remove-MailboxExportRequest -Confirm:$false
 

get-mailbox | %{New-MailboxExportRequest -Mailbox $($_.id) -FilePath \\SERVER.DOMAIN.local\pst\$($_.samaccountname).pst}

This powershell script is pretty simple. we add in the exchange snaping, kill any export requests that have failed, or previously completed, and may fail. Then export all of the mailboxes.

On the samba host, we are assuming that the server already is bound to the AD domain and allows for local and samba auth through sssd or realm.

When new-mailboxexportrequest exports your mailboxes, it needs rights to allow the “exchange trusted subsystem” to write to the samba share. In addition to this, you need to give rights to the machine account as it initiates the connection as the exchange server machine account.

the following is an example of the share within the samba config that you could use to export pst’s of user mailboxes to.



[pst]
        comment = pst
        valid users = some_user, +domain\"domain admins", xch2019_server\[email protected], +domain\"Exchange Trusted Subsystem"
        read only = no
        path = /mnt/pst
        create mask = 664
        inherit acls = Yes

Filed Under: IT Blog

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Copyright © 2025 · Beautiful Pro Theme on Genesis Framework · WordPress · Log in