SharePoint Search Index Backup and Restore: A Tested PowerShell Workflow

A working DR farm does not automatically mean a working search experience. You can have application servers, content databases and a Search Service Application ready, yet still face a separate question: how will you populate the search index?

That question led us to a focused PowerShell workflow for backing up an index and restoring it into an existing target Search Service Application (SSA). We tested the script and it worked. This article explains the mechanism, the operational decisions around it, and the checks that make the result useful.

The distinction matters: this is index backup and restore, not a claim that the entire search application, its configuration and its crawl history move together. Microsoft provides the underlying cmdlets. Our script brings them together into a repeatable backup-and-restore procedure.

If you already followed the search topology deployment article, this is the next operational question: how do you recover the index that topology serves?

What We Wanted to Recover

The search index is a processed representation of content, not a backup of the original documents. Crawling and content processing build it; query processing uses it to answer searches.

Rebuilding it through a full crawl is one possible recovery route. Restoring a suitable index backup is another. Which is preferable depends on the available backup, index size, source availability, target configuration and the recovery window. A restore is not automatically faster in every environment.

These are different recovery scopes:

Recovery approachWhat it providesWhat not to assume
Index-only backup and restoreA saved index restored into a target SSAIt does not also restore SSA databases or configuration
Full SSA backup and restoreSearch databases, service configuration and index filesIt is a broader recovery operation with its own prerequisites
New crawlAn index built from accessible source contentIt does not recover the old SSA’s configuration or analytics history

Microsoft’s SSA backup guidance also makes an important distinction: even when an SSA backup uses the differential option, its index files are backed up in full. That is separate from the two phases of the index-specific backup described below.

Index replicas solve a different problem again. They improve availability within a search topology. They do not give you an independently retained recovery point if an unwanted change affects the running index.

The Complete Sequence

The index backup cmdlet operates in two phases:

  1. Phase 1: capture the index state while the source SSA remains operational.
  2. Pause the source SSA.
  3. Phase 2: capture the changes since phase 1 began.
  4. Resume the source SSA after the phase-2 operation, checking for errors.
  5. Make the completed backup available to the target farm.
  6. Restore it into the intended, prepared target SSA.
  7. Verify the restore operation, component health and search behavior.
Conceptual workflow: phase 1, pause, phase 2, resume the source, then restore the completed backup into a prepared target SSA and verify it
Conceptual workflow, not a screenshot or representation of our measured topology. Resuming the source is part of backup cleanup; the source does not need to remain paused while the target restore runs.

A backup handle file links the two backup phases. The restore operation later returns its own handle for progress checks. These are related concepts, but they are not interchangeable parameters.

Phase 2 completes this backup operation. It is not an ongoing replication stream that keeps a second farm current. A retained backup can be reused where appropriate; do not confuse that with repeatedly running phase 2 as a permanent synchronization job.

Prepare the Source, Share and Target

Run the SharePoint commands from an elevated SharePoint Management Shell with the appropriate search administration permissions. Use your installed build’s command help as well as the online references:

Get-SPFarm | Select-Object BuildVersion
Get-Command Backup-SPEnterpriseSearchServiceApplicationIndex,
Restore-SPEnterpriseSearchServiceApplicationIndex
Get-Help Backup-SPEnterpriseSearchServiceApplicationIndex -Full
Get-Help Restore-SPEnterpriseSearchServiceApplicationIndex -Full

Our source script targets SharePoint Subscription Edition (SPSE). The linked index cmdlet reference pages list older SharePoint Server versions. Our successful test is operational experience, not a substitute for confirming the support requirements of your exact deployment.

Select the SSA explicitly

Do not depend on a farm having only one search application:

Get-SPEnterpriseSearchServiceApplication |
Select-Object Name, Id

Record the source SSA, intended target SSA and backup run identifier. On a multi-SSA farm, a correct command against the wrong application is still the wrong recovery.

Use a dedicated backup share

Our wrapper rejects administrative drive shares such as \\server\D$. Use a normal UNC share and grant the necessary share and NTFS access to the identities participating in backup and restore. Your interactive account being able to browse the folder is not enough to prove the search services can use it.

Use a separate folder per backup run, for example:

\\backuphost\SearchIndex\Run-001

Check capacity and connectivity from the participating servers on both sides. Protect the backup as sensitive data: indexed text, metadata and access-control information should not be placed on a broadly accessible share.

Plan a maintenance window for the source pause. Phase 1 can be substantial, and phase 2 still requires a pause even though it captures changes rather than starting the full copy again. Measure the impact instead of promising a fixed number of seconds.

Prepare the target topology

The target SSA must already exist for this workflow. Prepare matching source/target index partition counts and an appropriate active topology before restore. Count distinct partition ordinals, not component instances: multiple replicas of one partition do not make multiple partitions.

The wrapper logs the target partition count, but it does not compare it with a source manifest or enforce a match. That remains an operator prerequisite.

For topology decisions, use the earlier topology design and index distribution articles rather than trying to redesign the destination during restore.

Back Up the Index: Native Sequence

The following is a sanitized, illustrative sequence, not a transcript from our test. It makes the phase boundaries explicit and uses stricter pause checks than the current wrapper. Validate the pause/resume methods against your installed build before adopting it.

First select the source and verify that it is not already paused. An existing pause may belong to another administrator or maintenance operation.

$ssa = Get-SPEnterpriseSearchServiceApplication `
-Identity "Primary Search SSA" -ErrorAction Stop
$backupFolder = "\\backuphost\SearchIndex\Run-001"
$handleFile = Join-Path $backupFolder "indexbackuphandle.txt"
if ([int]$ssa.IsPaused() -ne 0) {
throw "SSA is already paused. Resolve that state before this run."
}
Backup-SPEnterpriseSearchServiceApplicationIndex `
-Phase 1 `
-SearchApplication $ssa `
-BackupFolder $backupFolder `
-BackupHandleFile $handleFile `
-Retries 3 `
-ErrorAction Stop

The backup share and run folder must be prepared and accessible. Keep the handle file and backup set together. The presence of files proves that something was written, not that both phases completed successfully.

After phase 1 succeeds, pause the SSA and run phase 2 using the same backup folder and handle file:

$pauseAttempted = $false
try {
if ([int]$ssa.IsPaused() -ne 0) {
throw "SSA pause state changed. Stop and investigate."
}
$pauseAttempted = $true
$ssa.Pause()
if ([int]$ssa.IsPaused() -eq 0) {
throw "Pause is not confirmed. Do not start phase 2."
}
Backup-SPEnterpriseSearchServiceApplicationIndex `
-Phase 2 `
-SearchApplication $ssa `
-BackupFolder $backupFolder `
-BackupHandleFile $handleFile `
-Retries 3 `
-ErrorAction Stop
}
finally {
if ($pauseAttempted) {
$ssa.Resume()
}
}

Run this in an exclusive maintenance window: do not let other automation change the SSA pause state concurrently. If pause-state inspection throws an error, phase 2 does not run. The cleanup attempts to resume after this procedure’s pause attempt; verify the source state afterward, including when a command failed.

Do not improvise a retry strategy by deleting handle files or assuming every interrupted backup resumes automatically. Preserve the error details and backup artifacts, then use the installed cmdlet’s documented retry/abort behavior for that situation.

What Our Wrapper Adds

Our 5.Sync-SearchIndex.ps1 script exposes two operations. The backup invocation is:

.\5.Sync-SearchIndex.ps1 -Operation BackupIndex `
-SearchServiceApplicationName "Primary Search SSA" `
-BackupFolder "\\backuphost\SearchIndex\Run-001"

Invoke it once. BackupIndex runs phase 1, attempts to pause, runs phase 2 and attempts to resume. It is not a phase-2-only entry point.

The useful operational additions are timestamped logs and transcripts, backup-handle path management, administrative-share rejection, retry parameters and free-space reporting. An optional -MinFreeGB threshold aborts before backup when a readable free-space value is below the configured limit. If free space cannot be determined, the script warns instead.

There are boundaries worth understanding before unattended use:

  • If Pause() succeeds but IsPaused() cannot be read, the current wrapper warns and proceeds. The native example above deliberately stops before phase 2 in that situation.
  • Phase-2 errors are logged, but a final message naming the backup output folder can still appear. Review the phase results, not just the last console line.
  • Resume is attempted in cleanup; it is not a guarantee that the SSA is healthy afterward.
  • -WhatIf previews the main operation, but logging and backup-directory creation can still occur.

The wrapper examples explain our operational interface. This article does not bundle the private source script or require it: the native commands above show the underlying mechanism.

Restore Into the Prepared Target SSA

Destructive operation: index restore clears and replaces the target SSA’s current index. Confirm the farm, SSA and backup run before proceeding. Use a disposable recovery target or retain an independent recovery path for its existing index.

Do not restore over a serving production index simply to find out whether a backup works.

On the target farm, select the SSA and inspect its state:

$target = Get-SPEnterpriseSearchServiceApplication `
-Identity "DR Search SSA" -ErrorAction Stop
Get-SPEnterpriseSearchStatus -SearchApplication $target -Text

With the completed backup accessible to the target services, start the restore:

$restoreHandle = Restore-SPEnterpriseSearchServiceApplicationIndex `
-SearchApplication $target `
-BackupFolder "\\backuphost\SearchIndex\Run-001" `
-AllReplicas `
-Retries 3 `
-ErrorAction Stop
Restore-SPEnterpriseSearchServiceApplicationIndex `
-SearchApplication $target `
-Handle $restoreHandle `
-ErrorAction Stop

The first call starts restore and returns its handle. The second uses that handle to inspect progress; repeat the status call as needed. Do not restart the destructive restore just to check how far it has progressed.

-AllReplicas requests restoration to all replicas, rather than only the primary replica. It is not a switch for selecting a subset of index partitions.

The examples intentionally omit -AllowMove. That option moves rather than copies files and can consume the source backup files. Preserving the backup is usually the safer starting point for recovery rehearsal.

Microsoft’s restore example includes a spbr0000 backup directory. Our wrapper also accepts a backup folder parameter, but an arbitrary directory with that name is not necessarily a valid index backup. Identify the actual compatible backup set; if a folder is rejected, do not rename or rearrange files to make it look like one.

The equivalent wrapper invocation is:

.\5.Sync-SearchIndex.ps1 -Operation RestoreIndex `
-SearchServiceApplicationName "DR Search SSA" `
-BackupFolder "\\backuphost\SearchIndex\Run-001" `
-AllReplicas -Poll

This targets an existing SSA rather than recreating the whole application. It does not establish that full SSA restore is impossible when server names differ: Microsoft’s broader recovery guidance also describes a RestoreMethod New path. Index-only restore is a narrower choice, not a universal replacement.

Monitor Progress Without Overstating Completion

A long restore needs visibility. Our wrapper records handle status and watches index-component health and searchable-item counts. That is more useful operationally than leaving the administrator with no feedback.

However, its -Poll loop uses heuristics. It can stop after positive counts remain stable while index components are active. It can also infer completion from sustained component health when count queries keep failing.

Treat those signals as reasons to investigate or proceed to verification, not independent proof that every item was restored. Query totals can depend on the query and security context; a stable total is not an authoritative inventory.

Likewise, -ExpectedItemCount is used for a progress display, not as a completion requirement. A polling time limit ending does not necessarily mean the server-side restore has stopped.

Retain the restore handle, inspect operation status and errors, and check component health together:

Get-SPEnterpriseSearchStatus -SearchApplication $target -Text

Health reporting establishes component state. It does not, by itself, prove correct query routing, freshness, permissions or a successful end-user recovery.

Verify the Recovery in Layers

These are recommended acceptance checks, not a list of results asserted about our test.

1. Operation and topology

Review the restore status and errors. Confirm the expected partitions and replicas exist in the target topology and investigate degraded or failed components. Do not mistake partial query availability for completion of every recovery task.

2. Direct SSA queryability

Run known queries against the intended SSA and inspect actual titles, paths and metadata, not just a nonzero result count. Our separate query-test script serves this smoke-test role.

An administrator’s direct SSA query is useful evidence, but it bypasses some of the path a normal user’s search request takes.

3. User-facing behavior

Confirm that the target web application uses the intended search proxy and SSA. Search through the actual site experience with representative users.

Include both positive and negative permission checks: users should find content they can access and should not receive restricted results. An HTTP success response alone does not establish either.

Check that result URLs resolve to the intended content location and that the required schema, query rules and result sources have been prepared separately.

4. Freshness and subsequent crawling

The backup captures indexed state, not every change in the source content system at that time. Content not yet crawled cannot appear merely because an index backup was taken.

Inspect the target’s crawl state and schedules instead of assuming restore has started or stopped crawling for you. This index-only operation does not transfer the crawl databases or establish that a short incremental catch-up is possible.

When you test subsequent crawling, use controlled content additions, updates and deletions. Observe the result and record what crawl was required. The earlier crawl performance article provides context for controlling that workload.

Make It a Recovery Procedure, Not Just a Command

Before each backup, record the SSA identity, build, topology, run folder, permissions and planned pause window. Afterward, retain the phase results and confirm the source resumed successfully.

Before each restore, identify the backup set and target SSA, confirm partition alignment, protect the target’s existing index where needed and verify storage access.

For acceptance, keep the operation status, component checks, sample queries, representative-user checks and any subsequent crawl results together. Measure backup, pause, transfer, restore and validation durations separately.

Your recovery point is bounded by the indexed state in the completed backup. Your recovery time includes the work needed to restore and validate service, and may also include preparing the target or retrieving the backup. Neither is a number to infer from the script’s progress display.

The successful test gave us a practical index recovery path to build on. The important lesson is not that one cmdlet solves search DR. It is that the backup phases, source cleanup, target preparation, destructive restore and acceptance checks form one procedure.

Use that procedure for what it recovers: the index. Keep full SSA recovery, configuration, source-content protection and ongoing freshness in the wider recovery plan.

Sources

  1. Backup-SPEnterpriseSearchServiceApplicationIndex – Microsoft cmdlet reference.
  2. Restore-SPEnterpriseSearchServiceApplicationIndex – Microsoft cmdlet reference.
  3. Back up Search service applications – Full SSA backup scope, including Subscription Edition.
  4. Restore Search service applications – Broader search application recovery.
  5. Search DR best practices – SharePoint 2016 architectural background; not blanket SE support certification.

Leave a Reply