Skip to content

Repository files navigation

SPSDBMove

Pester Release License: MIT Contributor Covenant PowerShell 7.0+

Backup, copy, and restore SharePoint SQL databases across SQL Server instances — designed for two common scenarios:

  • SharePoint Server 2016 / 2019 → Subscription Edition migrations.
  • PROD → PRE-PROD content refreshes.

SPSDBMove is a single PowerShell script that orchestrates the three phases end-to-end (or any phase individually):

  1. Backup — BACKUP DATABASE ... WITH COPY_ONLY, COMPRESSION, CHECKSUM on the source instance, written into a per-database folder layout (<root>\<DbName>\FULL\<DbName>_<timestamp>.bak).
  2. Copy — parallel file copy of the latest .bak per database from the source share to the destination share.
  3. Restore — RESTORE DATABASE ... WITH REPLACE, RECOVERY on the destination instance, with automatic logical-to-physical file remapping.

Companion project: luigilink/SPSUpdate.


Requirements

Component Version
PowerShell 7.0 or later (the Copy phase uses ForEach-Object -Parallel)
SqlServer module 21.1.18256 or later
Source SQL Server 2016 / 2017 / 2019 / 2022
Destination SQL Server 2019 / 2022 (SharePoint SE compatible)
Account rights dbcreator + BACKUP DATABASE on source; dbcreator on destination; read/write on both backup shares

Install the SQL module once:

Install-Module -Name SqlServer -Scope CurrentUser -Force

Quick start

SPSDBMove is configuration-driven: the job (instances, backup roots, database list, tuning) lives in a small JSON file; the CLI takes only the config path, the phase to run, and a couple of runtime flags.

  1. Copy the sample config and edit it for your environment:

    Copy-Item .\scripts\SPSDBMove.sample.json .\scripts\my-refresh.json
    notepad .\scripts\my-refresh.json
  2. Run the full pipeline (backup → copy → restore):

    .\scripts\SPSDBMove.ps1 -ConfigPath .\scripts\my-refresh.json

Run a single phase

.\scripts\SPSDBMove.ps1 -ConfigPath .\scripts\my-refresh.json -Action Backup
.\scripts\SPSDBMove.ps1 -ConfigPath .\scripts\my-refresh.json -Action Copy
.\scripts\SPSDBMove.ps1 -ConfigPath .\scripts\my-refresh.json -Action Restore

CLI surface

Parameter Purpose
-ConfigPath (alias -Path) Required. Path to the JSON job file.
-Action All (default), Backup, Copy, or Restore.
-SqlCredential Optional [pscredential] for SQL auth. Kept on the CLI so secrets stay out of the JSON.
-SkipExisting Copy phase only: skip files already at the destination with the same size.
-WhatIf / -Confirm Standard PowerShell, honored by every destructive operation.

Everything else (SourceInstance, DestinationInstance, SourceBackupRoot, DestinationBackupRoot, DataFileDirectory, LogFileDirectory, ThrottleLimit, OverwriteDestinationDb, Databases, ExcludeDatabases) belongs in the JSON file. See scripts/SPSDBMove.sample.json and Configuration.

Dry-run

SPSDBMove honours -WhatIf for every destructive operation:

.\scripts\SPSDBMove.ps1 -ConfigPath .\scripts\my-refresh.json -WhatIf

Documentation

Full documentation lives in the wiki:

Contributing

See CONTRIBUTING.md. Bug reports and feature requests use the issue templates.

Changelog

See CHANGELOG.md and the latest release notes.

License

MIT © 2026 Jean-Cyril Drouhin.

About

Backup, copy, and restore SharePoint SQL databases across SQL instances — for SP2019/SP2016 → SE migrations.

Topics

Resources

Code of conduct

Contributing

Stars

1 star

Watchers

0 watching

Forks

Releases

Contributors

Languages