DBA Tooling · dtcSoftware · 2026

SQL Server
Migration Tool

Two-phase database migrations via a WinForms GUI -
even without a direct network connection between the source and target server

SQL Server 2016 - 2025 Windows Server 2016+ PowerShell 5.1 dbatools 2.x WinForms GUI

Uwe Janke  ·  Senior SQL Server DBA  ·  dtcSoftware

Motivation

The Problem

SQL Server migrations in complex network environments - manual, error-prone, not reproducible.

🌐

No direct connection

Source and target server in separate network segments, a DMZ, or different data centers - no direct SQL access possible

📋

No log

What was migrated? Which databases? Which version? No structured log, no evidence

⏱️

Manual effort

Backup on the source, transfer the file, restore on the target, create logins manually, recreate jobs - different every time

🔄

Not reproducible

A new migration? A different DBA? No defined process - reinvented every time, different every time

🔐

Forgotten objects

Logins, SQL Agent jobs, linked servers, or SSIS packages get forgotten or migrated inconsistently

🧪

No WhatIf

No way to simulate the migration beforehand - errors only surface in production

Overview

The Solution

One tool, one process, one log. Pick a role - the rest runs automatically. Even without a direct network connection.


🖥️

WinForms GUI

Role selection at startup (Source / Target / Auto). Only the relevant side is shown

🔀

Two-phase concept

Phase 1 on the source server, phase 2 on the target server - a JSON state file as the secure link

🔍

Auto-detection

Target server reachable: direct mode. Not reachable: TwoPhase mode. Automatic, no intervention needed

BeforeAfter
Manual multi-hour processAutomated, structured
Separate networks = manual data transferTwoPhase mode with a state file
Logins / jobs forgottenComplete object migration
No log, no evidenceStructured log, every step
No testing possibleWhatIf simulates everything in advance
✓ Tested on Windows Server 2022 · SQL Server 2022 · Backup/Restore and Detach/Attach
Deep Dive

The Two-Phase Concept

Migrations work - even when the source and target don't know each other.

Concept

Two-Phase Migration

Core idea: the migration is split into two independent phases that communicate via a JSON state file.

Phase 1 - Source Server

📤 Export

  • Back up databases
  • Export logins
  • Back up SQL Agent jobs
  • Capture linked servers
  • Export SSIS packages
  • Write the state file
Phase 2 - Target Server

📥 Import

  • Read the state file
  • Restore databases
  • Create logins
  • Import SQL Agent jobs
  • Set up linked servers
  • Deploy SSIS packages
ℹ Direct mode If the target server is TCP-reachable, the migration runs completely in one pass - no manual file transfer needed.
⚡ TwoPhase mode Transfer the state file and backup files to the target server via an exchange path (network share, SFTP, USB).
User Interface

WinForms GUI - Phase 1 (Source Server)

SQL Migration Tool v1.1 - Source Server (Phase 1)
① Source Server Connection
SQL instance
SQLSRV01\INST1
Authentication
Windows Auth
② Databases
☑ AdventureWorks2022
☑ Northwind
☐ ReportServer
☐ msdb
③ Migratable Objects
Logins
SQL Agent Jobs
Linked Server
SSIS Packages
④ Migration Method
Backup / Restore
Detach / Attach
⑤ Paths
Backup directory
\\FILESERVER\SQLBackup\Migration
Exchange path
\\FILESERVER\SQLBackup\Migration\state
⑥ Options
WhatIf (simulation)
Compression
⑦ Progress
[10:42:11]Connection to SQLSRV01\INST1: OK [10:42:12]Inventory: 2 databases selected [10:42:15]Backup AdventureWorks2022: OK (1.2 GB) [10:42:31]Backup Northwind: running...
Cancel
Check WhatIf
▶ Start Phase 1
Phase 1 - Source Server - Backup running
65%
Workflow

4-Phase Workflow

1
Role selection
Source / Target / Auto
2
Connection & inventory
Read DBs, logins, jobs
3
Phase 1 - Export
Backup + state file
4
Phase 2 - Import
Restore + objects

Phase 1 - Source Server

1
Connection & inventory

All databases, logins, jobs, and linked servers are read in and offered for selection

2
Backup / detach

Selected databases are secured via backup/restore or detach/attach (with compression)

3
Export objects

Logins, Agent jobs, linked servers, and optionally SSIS packages are serialized into the state file

Phase 2 - Target Server

4
Read the state file

The JSON file with all migration information is loaded from the exchange path and validated

5
Restore / attach

Databases are restored on the target server - including backup path mapping

6
Import & verify objects

Create logins, import jobs, set up linked servers. A complete log of every step

Deep Dive

Migration Methods

📦 Backup / Restore

The classic, safe method. The database stays online on the source server while the backup runs.

Online operation possible
Compression reduces file size
Checksum validation
~Longer migration time

🔗 Detach / Attach

A fast method for planned maintenance windows. The database is briefly taken offline.

Faster data transfer
No backup overhead
~Brief downtime needed
~A maintenance window is required

Migratable Objects

ObjectMethodNotes
DatabasesBackup/Restore or Detach/AttachWith path mapping for differing drives
LoginsSID transfer via dbatoolsWindows and SQL logins, DB permissions
SQL Agent JobsExport / importAG sync jobs can optionally be excluded
Linked ServerSerialized via the state fileCredentials are not transferred
SSIS PackagesSSISDB export / deployOptional, only when SSIS is installed
Configuration

migration.config.json

All paths and default options in a single JSON file - read automatically at startup. GUI input overrides the configuration at runtime.

// migration.config.json
{
  "ExchangePath":
    "\\\\FILESERVER\\SQLBackup\\state",
  "BackupDirectory":
    "\\\\FILESERVER\\SQLBackup",
  "LogPath":
    "C:\\Logs\\SQLMigration",
  "MigrationMethod": "BackupRestore",
  "WhatIf":          false,
  "MigrateLogins":   true,
  "MigrateAgentJobs":true,
  "MigrateLinkedServer":true,
  "MigrateSsis":     false
}

Operating Modes

ModeDescription
SourcePhase 1 only - export on the source server
TargetPhase 2 only - import on the target server
AutoState file present → Target, otherwise → Source

Startup Parameters

# Interactive (role selection via dialog)
.\SQL-Migration.ps1

# Specify the role
.\SQL-Migration.ps1 -Role Source
.\SQL-Migration.ps1 -Role Target

# WhatIf simulation
.\SQL-Migration.ps1 -WhatIf
Quality & Safety

WhatIf Mode & Logging

🧪 WhatIf Mode

Every migration step is fully simulated - without a single change to the system.

1
Check connections

The SQL connection to the source and target is tested and logged

2
Inventory objects

All databases, logins, and jobs to be migrated are listed

3
Detect conflicts

Databases or logins already present on the target server are reported

4
Output a report

A complete WhatIf log shows what would happen - without executing anything

⚡ Recommendation Always test with -WhatIf first before every production migration.

📋 Structured Logging

Every step is logged with a timestamp, status, and error message.

[2026-05-22 10:42:08] INFO Migration started - role: Source [2026-05-22 10:42:09] INFO Connection SQLSRV01\INST1: OK [2026-05-22 10:42:11] OK Inventory: 2 DBs, 15 logins, 8 jobs [2026-05-22 10:42:15] OK Backup AdventureWorks2022 (1.2 GB) [2026-05-22 10:44:03] OK Backup Northwind (320 MB) [2026-05-22 10:44:05] OK Logins serialized: 15 [2026-05-22 10:44:06] OK Agent jobs serialized: 8 [2026-05-22 10:44:06] WARN Linked server: credentials not transferred [2026-05-22 10:44:07] OK State file written: migration_state.json [2026-05-22 10:44:07] OK Phase 1 complete - duration: 1:59 min
Preparation

Prerequisites

System Requirements

RequirementNote
Windows Server2016 or newer - source and target server
SQL Server (source)2016 or later - Enterprise or Standard
SQL Server (target)2016 to 2025 - equal to or higher than the source
PowerShell 5.1Preinstalled on WS 2022
dbatools ≥ 2.0Installed automatically
Local administratorOn the source and target server
Network share reachableFor the exchange path (TwoPhase)
ℹ Named instances The tool fully supports named instances - the instance name is stored in the state file and applied on the target server.

Network Scenarios

A
Direct mode (recommended)

Both servers reachable on the same network → fully automatic in one run

B
TwoPhase - network share

Exchange path on a mutually accessible share → state file + backups handed over automatically

C
TwoPhase - physically separated

State file + backup folder transferred between sites via SFTP, USB, or courier

✓ Both servers in the same domain Windows auth (Kerberos) is preferred - no SQL login needed.
Ecosystem

Toolchain Integration

The Migration Tool is part of a complete DBA toolchain - each tool covers a clearly defined area of responsibility.

🔧 SQLSetupTool

Standardized SQL Server installation on the target server - before the migration begins.


SQLSetupTool

📦 Migration Tool

Transfers databases, logins, jobs, and configuration from the old system to the new one.


◉ This Tool

📊 sqmSQLTool

Ongoing operations: backup, monitoring, health checks, AG sync on the target server.


sqmSQLTool
ℹ Typical flow SQLSetupTool → Migration Tool → sqmSQLTool. The tools can be used independently, but are designed to be used as a sequence.

Scope & Boundaries

✓ In scope

  • Databases, logins, jobs, linked servers, SSIS
  • Backup/Restore and Detach/Attach
  • Direct and TwoPhase mode
  • WhatIf simulation, structured log

✗ Not in scope

  • Windows Server migration / configuration
  • Firewall rules, DNS, SPN
  • In-place upgrade (a separate tool)
  • Linked server credentials
Conclusion

Summary

Two-phase migration

Works even without a direct network connection - a JSON state file links the source and target server

Complete object migration

Databases, logins, Agent jobs, linked servers, and SSIS packages in one controlled process

WhatIf before every migration

Full simulation with no system impact - conflicts and errors are detected in advance

Auto-detects the mode

Direct or TwoPhase - the tool decides automatically based on network reachability

Structured log

Every step logged - timestamp, status, error message. Evidence for every change

Resources:

github.com/JankeUwe/SQLMigration www.powershelldba.de
Uwe Janke  ·  Senior SQL Server DBA  ·  dtcSoftware  ·  2026