Exchange 2019, 2016, 2013, 2010 mailbox backup by export to PST (PowerShell)

xor
Verified
SupModer
SupModer
Сообщения: 321
Зарегистрирован: 26 ноя 2015, 17:49

Exchange 2019, 2016, 2013, 2010 mailbox backup by export to PST (PowerShell)

Сообщение xor »

Source: https://www.codetwo.com/admins-blog/exc ... pros-cons/

Exchange 2019, 2016, 2013, 2010 mailbox backup by export to PST (PowerShell)

An email organization lives and dies by mailbox backups. Unfortunately, all Microsoft Exchange versions, including Exchange 2019 and 2016, come with limited brick-level backup capabilities. Basically, the only available granular option is an export to PST files. This can be done via Outlook (obviously), PowerShell and in some cases also via Exchange Management Console / Control Panel. In this article I discuss the options available via PowerShell in: Exchange 2019, Exchange 2016, Exchange 2013 and Exchange 2010.

If you prefer a video guide of this process, visit Export Exchange mailbox data to PST with PowerShell (video guide).

Note: To export Exchange 2007 mailboxes to PST files, use the Export-Mailbox cmdlet. If you are using Exchange Online, exporting mailboxes to PST requires a different approach, described in this article.

Reasons for exporting mailboxes to PST
Before we get down to scripting, I would like to say a few words about mailbox export to PST and PST files in general.

PST (Personal Storage Table) files have been the primary means of mailbox backup since early versions of Outlook. While newer, modern Outlook versions depend primarily on OST (Offline Storage Table) files, PSTs are still there. That’s because they require no third-party tools plus are simple to use and supported by pretty much any Outlook version. Additionally, both users and admins can export mailbox items to this format.

The three main purposes of PST files are as follows:

  • Mailbox data backup

  • Archiving

  • Migration (for example from Exchange 2010 to Exchange Online)

Single mailbox export to PST file
Exporting Exchange mailbox contents to a PST file is achieved using the MailboxExportRequest cmdlet. It has only 2 obligatory parameters: –FilePath – defines the network share path of the PST file to which you want to export the data; and –Mailbox – defines the Alias, SMTP address or Display name of the mailbox you will export. Requirements:

  • The user performing the export must be a member of a role group which has the Mailbox Import Export role added. The easiest way to assign it is running this script:

    Код: Выделить всё

    New-ManagementRoleAssignment -Role "Mailbox Import Export" -User "<user name or alias>"

    To learn more see the “Add a role to a role group” section of this Microsoft article.

  • The location to which you will export the PST file must be a shared folder.

Syntax
Here is an example of a mailbox export request, which backs up an entire mailbox to a PST file:

Код: Выделить всё

New-MailboxExportRequest -Mailbox <user> -FilePath \\<server FQDN>\<shared folder name>\<PST name>.pst

Limiting the scope of exported contents is possible using additional parameters, e.g.:

-ContentFilter
Specifies what conditions the contents of a mailbox have to match to be exported into the PST file. The conditions are provided in the form of standard PowerShell logical clauses with several item properties available for filtering (wildcards are supported). Example of a script that exports items received prior to 2013-01-01 with subjects beginning with fwd:

Код: Выделить всё

New-MailboxExportRequest -Mailbox <user> -ContentFilter {(Received -lt '01/01/2013') -and (Subject -like 'fwd*')} -FilePath \\<server FQDN>\<shared folder name>\<PST name>.pst

-ExcludeFolders and -IncludeFolders
Just what it sounds like. You can choose from all Exchange mailbox folders. There are also two interesting features available:

  • The capability to filter personal folders located under root folders using the <FolderName>/* syntax.

  • The capability to filter well known Exchange mailbox folders regardless of their name in a local language using the #<FolderName>#/* syntax.

Here is an example of a script that exports only the Inbox and Sent Items folders:

Код: Выделить всё

New-MailboxExportRequest -IncludeFolders "#Inbox#/*","#SentItems#" -Mailbox <user> -FilePath \\<server FQDN>\<shared folder name>\<PST name>.pst

-IsArchive
A switch parameter, which defines the archive as the only source of the export. Example:

Код: Выделить всё

New-MailboxExportRequest -Mailbox <user> -IsArchive -FilePath \\<server FQDN>\<shared folder name>\<PST name>.pst

-Name
Sets the name of an export request. Useful for tracking or if you want to set more than 10 export requests per a single mailbox. This is because by default Exchange assigns only 10 consecutive names to export requests related to a single mailbox (starting with MailboxExport through MailboxExport9) and then stops. To proceed when all 10 default export request names have been taken, you have to either flush your export requests or start assigning your own names using the Name parameter. Example:

Код: Выделить всё

New-MailboxExportRequest -Name <unique name> -Mailbox <user> -IsArchive -FilePath \\<server FQDN>\<shared folder name>\<PST name>.pst

Additional information
A single MailboxExportRequest script can, of course, contain multiple parameters, including ones I didn’t mention. For a full list of available parameters, as well as syntax information and other details, consult this Microsoft article.

Bulk mailbox export to PST file

The requirements here are identical as in the case of single mailbox exports:

  • The user performing the export must be a member of a role group which has the Mailbox Import Export role added (see previous section for more).

  • The location to which you will export the PST file must be a shared folder.

Method 1
Save all mailboxes to a variable (in my case it’s AllMailboxes):

Код: Выделить всё

$AllMailboxes = Get-Mailbox

Export all mailboxes to PST files with names based on mailbox aliases (to use a different mailbox property replace the phrase “Alias” with its name):

Код: Выделить всё

$AllMailboxes|%{$_|New-MailboxExportRequest -FilePath \\<server FQDN>\<shared folder name>\$($_.Alias).pst}

Additional parameters can be used just as in single mailbox exports (see the first section of this article).

Method 2
Run the below script for the same effect as in Method 1 (the only difference is the use of the foreach command instead of piping):

Код: Выделить всё

foreach ($Mailbox in (Get-Mailbox)) { New-MailboxExportRequest -Mailbox $Mailbox -FilePath "\\<server FQDN>\<shared folder name>\$($Mailbox.Alias).pst" }

Limiting the scope of exported mailboxes
You will notice that the methods I describe result in exporting all mailboxes located on your servers. If you want to limit the scope of exported mailboxes, you can do so e.g. using the Get-Mailbox -Filter parameter. Here is an example of a script which lists mailboxes belonging to a security group called export1.

Код: Выделить всё

Get-Mailbox -Filter {MemberOfGroup -ne $export1}

NOTE: Using the -Filter parameter with the Get-Mailbox cmdlet results in excluding mailboxes that are defined in the parameter. This is why, to limit the scope of exported mailboxes to e.g. Batch1, you have to use the -Filter parameter to exclude all mailboxes that are not part of Batch1 – hence the use of the -ne (not equals) operator. Adding the -Filter parameter to the Get-Mailbox cmdlets in Method 1 and Method 2 scripts will result in limiting the scope of exported mailboxes.

Mailbox backups to PST file: The bright and the dark side
All in all the drawbacks seem to outweigh the advantages, mainly due to clunky PST handling options and due to the files themselves being rather unstable:

Pros

  • Brick-level backups with item filtering capability

  • Support for mass mailbox backups

  • Customizability

  • Available for free

Cons

  • Fragility and corruptibility of PST files

  • Limited search capability (only per-PST, upon import)

  • No item preview

  • No central management for backup jobs, storages, etc.

  • Lack of backup statistics

  • Increased execution difficulty due to PowerShell usage

  • Risk of data loss

  • Backup content preview only via Outlook

  • No versioning or incremental backup options (high disk space consumption)

  • Scheduling possible only via Windows Task Manager

Easy brick-level Exchange mailbox backups
You can have all the advantages of a PowerShell assisted mailbox-to-PST backup without its drawbacks. CodeTwo Backup for Exchange allows for secure granular mailbox backups to a stable and easily managed database. The software allows for scheduling multiple simultaneous backup and restore jobs, includes a smart versioning mechanism, full item search and preview, and additionally, allows for archiving storages to PST files as one of two available archiving models Learn more about CodeTwo Backup examples of use

Mailbox migration via PST: Pros and cons
As I’ve already mentioned, PST files can be used to migrate from one Exchange Server to another (including Exchange Online). This migration method is also called the manual migration – you don’t create migration endpoints, but rather recreate environment from scratch and import the mailbox contents from CSV files afterwards.

Pros

  • All target servers supported

  • Direct migration (without double-hop) from older Exchange Server versions

  • Exporting via PowerShell allows you to filter content to some extent

  • Available for free

Cons

  • Requires a lot of manual labor

  • Manageable only for few mailboxes

  • No way to encrypt PST files on the move

  • PST file corruptibility

  • Lack of migration reports or logs

  • Slow migration speed

  • Risk of data loss

  • No option for delta migration

  • No scheduling

Exchange mailbox migration simplified
Realistically, if you have more than a couple of mailboxes to migrate, PST migration won’t do. The amount of work it requires together with poor reliability of PST files make it one of the most stressful procedures known to IT.

If you want to save yourself a lot of time and nerves, take a look at our migration solutions:

CodeTwo Exchange Migration – a tool which allows you to migrate from any Exchange Server version (2003+ or Exchange Online) or IMAP server directly to any other Exchange Server, including Exchange 2019.

CodeTwo Office 365 Migration – the solution which helps organizations migrate from any source server to Exchange Online. It also allows a Microsoft 365 cross-tenant migration

Both migration tools:

  • simplify and automate the migration process,

  • come with a detailed migration plan,

  • allow automatic mailbox creation,

  • support public folders migration,

  • are developed in accordance with ISO/IEC 27001 & ISO/IEC 27018-certified Information Security Management System (ISMS). You can be sure that the tools offer world-class security and reliability.

PS
To export and send email like in ecp:

Код: Выделить всё

$PathExport ="\\server\share\folder"
$mailboxName = "mailbox"
$NotifEmail = "admin@contoso.com"
New-MailboxExportRequest -mailbox "$mailboxName" -filepath "$PathExport\$mailboxName.pst" -name $mailboxName | Out-Null
Set-Notification -NotificationEmails ( "$NotifEmail" ) -Identity (Get-MailboxExportRequest -name $mailboxName |Get-MailboxExportRequestStatistics| Select -expand requestguid).guid
Ответить

Вернуться в «Электронная почта»