Why a Windows to Linux PostgreSQL move is a logical migration
If your PostgreSQL server runs on Windows and must move to Linux, you cannot copy the data directory across the platform boundary and expect it to start. The move is done logically, either by dumping and restoring the database or by replicating from the Windows server into a new Linux cluster with logical replication. Physical copies and pg_upgrade both depend on the on-disk layout and the platform that wrote it, so they are not options for a change of operating system. The same logic applies whether the source is a single instance or a larger cluster with standbys, because the standbys are rebuilt on Linux from the new primary rather than copied from Windows files.
Effort depends on three things you should measure before choosing a method: database size, collation and extension dependencies, and how much downtime the business will accept. Size drives how long a dump and restore or initial table copy takes. Collation and encoding settings determine whether indexes and sort order survive the move unchanged, so you must confirm them on both sides before any data loads. Extensions must exist on the Linux build at the same versions the application expects, and any extension that is unavailable there changes the plan. Ask any partner for a written estimate that states which of these three assumptions it relies on, and ask for it to be revised if your measurements differ. The PostgreSQL logical replication documentation describes replicating between different platforms as a supported use case, which is the starting point for the cutover design in the sections that follow.
What carries over from Windows and what must be rebuilt on Linux
This table compares each part of a Windows-hosted PostgreSQL server with its Linux counterpart and marks whether it moves as data, is re-created by hand, or needs a decision. Use it as a checklist during planning, since the rows that need a decision usually determine the cutover work.
| Element | On Windows | On Linux and how it moves |
|---|---|---|
| Table and row data | Stored in the data directory under the service's data path | Moves as data through pg_dump and restore or logical replication, never by copying the directory across platforms |
| Data directory | Windows path set when the service was installed | Re-created with initdb on Linux; the old directory is a source for dumps, not a file to reuse |
| Service configuration | Windows service registered with the server, often run under a service account | Re-created as a systemd unit or your init system's equivalent, with the service account and file permissions set by hand |
| postgresql.conf settings | Values tuned for the Windows host | Copied as values to review, not pasted blindly, because memory, I/O and path settings change on Linux |
| pg_hba.conf rules | Host-based access rules, with paths and methods written for Windows accounts | Rules carry over in concept but account names and methods must be rewritten; each method needs a decision |
| Windows authentication (SSPI) | Lets users with domain accounts log in without a password | Needs a decision: GSSAPI with Kerberos is the usual replacement, or LDAP, or certificates; confirm the directory design with your identity team |
| Collations and locale | Windows locale names and ICU or OS collation set at cluster creation | Locale names differ on Linux; check collation and encoding of every database and test sort order before cutover |
| Extensions | Installed as Windows binaries matched to the server version | Install matching Linux packages or build from source for the same major version; confirm each extension is available on your target |
| Scheduled jobs | Windows Task Scheduler runs backups, maintenance and scripts | Re-created with cron, systemd timers or your scheduler; credentials and log paths must be rebuilt |
| Backup tooling | Windows scripts, file-level copies or third-party agents | Re-created on Linux; old backup sets remain usable only for restores on the original platform, so keep them until the new backups are proven |
Documented paths for moving data off a Windows PostgreSQL server
Logical replication is the route to choose when the database is too large for a comfortable offline window or when the business cannot accept a long write freeze. The Windows server acts as the publisher, and a Linux server runs as the subscriber. The PostgreSQL documentation lists replicating between different platforms, such as Linux to Windows, as a logical replication use case, so the same mechanism applies in the reverse direction for this move. Initial table synchronization copies existing rows, and then changes stream across until the team cuts over.
- Publication setup: Define publications on the Windows source for the tables in scope, and confirm that every table has a primary key or a replica identity, because updates and deletes depend on it.
- Sequences and DDL: Logical replication does not carry schema changes or sequence values, so plan how DDL changes will be frozen and how sequences will be set on the Linux side at cutover.
- Subscriber sizing: The Linux subscriber must hold the full data set and keep up with the write rate during catch-up.
- Lag monitoring: Watch replication lag and slot retention on the publisher, since an unconsumed slot keeps WAL on the Windows disk.
- Scope limits: Confirm which object types your version replicates and handle the rest, such as large objects or certain extensions, separately.
Before cutover, confirm the exact logical replication behavior for your PostgreSQL version in the logical replication documentation and rehearse the switch.
Dump and restore is the simplest route and fits databases that can be taken offline for the full copy and restore window. Use pg_dump for one database, or pg_dumpall for the whole cluster including roles and global objects, then restore the output on the Linux server with pg_restore or psql, depending on the format. The output is logical, so it does not depend on the operating system's file layout, which is why it works across platforms. Smaller databases, test environments and databases with a tolerant maintenance window usually fit this path best.
- Global objects: Use pg_dumpall with the global option or dump roles and tablespaces separately, since pg_dump alone does not export roles.
- Parallel restore: Custom or directory formats with pg_restore can run parallel jobs, which shortens the restore on larger databases.
- Restore time: Measure a full rehearsal on Linux, since index builds and constraint checks often dominate the window.
- Encoding and collation: Confirm the target database encoding and collation match the source before restoring, because mismatches cause errors or sort-order changes.
- Verification: Compare row counts, checksums on critical tables and object counts after restore.
Check that the restore has been rehearsed against a copy of production data and that the downtime measured in the rehearsal fits the agreed window.
Two methods that are common within one platform do not work for this move. pg_upgrade changes the major version of a cluster in place, but it operates on the data directory of one installation and does not convert the on-disk format between Windows and Linux. Physical copies, such as copying the data directory or restoring a file-level base backup, depend on the binary layout, byte order, and file system conventions of the source, so the target cannot read them. Teams sometimes plan these steps by habit, so the migration plan should list them as excluded and say why.
- pg_upgrade limits: It is a same-platform, major-version tool, so it cannot be used to change operating systems in the same step.
- Physical base backups: A file-level backup taken on Windows is not a restore source on Linux.
- Combining steps: If the team plans a major version upgrade at the same time, pick a logical method that handles both changes.
- Documentation check: Confirm the current constraints in the upgrading documentation for your target version.
Before the project starts, ask the vendor or internal DBA team to confirm in writing which methods they consider supported for your exact source and target versions.
The right route depends on two variables: how much data must move and how long writes can stop. Small databases with a generous window are usually simplest to move with a dump and restore. Large databases or systems with strict availability needs usually favor logical replication, because the initial copy runs while the source stays live and only the final switch needs a short pause. Between these cases, teams often combine both routes, using a dump for the schema and bulk load of static tables, then logical replication for the tables that keep changing. Size and downtime figures for your system come from your own measurements, not from general guidance.
- Measure the source: Record total data size, largest tables and write rate during business hours.
- Set the downtime budget: Agree with the business owner the longest acceptable write freeze, including validation.
- Rehearse both paths: Time a full restore and a replication catch-up on a copy of the production data.
- Account for the cutover: Include sequence resets, application connection string changes and rollback steps in the window.
- Document the decision: Record the chosen method, the measured times and the rollback point in the migration plan.
Review the decision against the measured results from the rehearsal before committing to a cutover date.
How the Windows to Linux cutover is sequenced
The sequence turns an in-place Windows server into a tested Linux target, proves the data and application path with a pilot and a parallel run, and ends with a rollback point and a decommissioned source. Each step closes with a check that the next step depends on.
Inventory databases, roles, extensions and encodings
Record every database, role, tablespace path, installed extension, encoding, locale and collation setting on the Windows server, along with the application connection strings and any scheduled jobs that touch the database. Your DBA and the application owners do this together, because the inventory decides which migration path is possible. Done when the list is reviewed by both sides and every extension has a confirmed Linux package or a replacement plan.
Build the Linux target at a planned major version
Install PostgreSQL on Linux from packages or a build your team controls, using the major version you intend to run in production. Match the major version to the Windows source where you can, or plan the upgrade as a separate step with its own test. Set the locale, encoding and collation to the values recorded in the inventory before any data is loaded. Done when the target reports the same encoding and collation as the source and all required extensions load.
Set up backups and the rollback point
Before any cutover work, take a verified base backup of the Windows server and store a copy outside the source host. Record the exact recovery point, the WAL position or the dump timestamp, and document who can restore it and how long a restore takes in your environment. Keep the Windows server intact and read-write-capable until the rollback window closes. Done when a test restore of this backup has succeeded on a separate host.
Run a pilot restore and validate the data
Restore the backup or a dump to the Linux target and run the same validation queries against both systems. Compare row counts, checksums on critical tables, sequence values, index definitions and function behavior, and check the results of collation-sensitive sorts and comparisons. Note every difference, fix the cause and repeat the pilot until the results match. Done when the pilot validation report shows no unexplained differences.
Start replication and watch lag during the parallel run
Connect the Linux target as a subscriber using logical replication where the source version and schema support it, or set up a dump-based sync for smaller databases. Watch replication lag, failed apply errors and sequence drift for a sustained period that covers normal business load, including batch jobs. Run read-only comparison queries against both servers. Done when lag stays within the limit your team set in advance and the comparison queries agree.
Cut over applications to the Linux server
Put the application into a short write freeze, confirm replication has caught up, and resynchronize sequences. Then change connection strings, DNS or the pooler target to the Linux host and restart the application tier. Run smoke tests for login, core transactions and reporting before reopening writes. Done when the application runs against the Linux server, and the write freeze window and any errors are logged.
Hold the rollback window and then decommission Windows
Keep the Windows server available for the agreed rollback period, with a documented procedure for reversing the cutover if defects appear. Monitor the Linux server, backups and restore tests during this time. Once the window closes and the owners sign off, take a final archive of the Windows server, remove its replication and access paths, and retire the host. Done when the final archive is verified, access is removed and the decommission record is signed.
Collation and encoding checks that prevent silent data changes
Collation and encoding must be verified on the Linux target before any data loads, because a dump can restore cleanly while the data quietly changes meaning. Windows builds of PostgreSQL commonly use locale names and collation behavior that differ from glibc-based Linux locales, and an index built under one collation is only valid under the same collation. If the target sorts strings differently, a unique constraint can accept values that the source rejected, a range query can return different rows, and a btree index can return wrong results until it is rebuilt. None of these failures raises an error at load time, so the check has to happen before cutover.
Start by comparing the database encoding and the locale settings on both sides. Run SHOW server_encoding;, SHOW lc_collate; and SHOW lc_ctype; on the source, then list each database's encoding and collation from pg_database. On the target, confirm that the locales exist in the operating system and that the database is created with the same encoding and a collation you have chosen deliberately. Then list every index that depends on collation, including text columns with a non-default COLLATE clause, and record which indexes must be rebuilt after the move. Ask your team to confirm the exact locale names available on the Linux build, since names differ between distributions and the results cannot be assumed from the Windows side.
Verify the result with data, not just settings. Choose a sample of text columns that feed unique keys, sort orders and joins, and compare row counts and checksums of their sort order on both servers. Re-run any uniqueness or foreign key checks that rely on text comparison. Decide in advance whether the Linux server will use a single collation for the whole cluster or per-database collations, and document that decision with the application team, because it determines what the application sees after cutover. Confirm each step against your own environment and sign off the results before the cutover window opens.
What drives the cost and duration of this move
Re-platforming PostgreSQL from Windows to Linux is priced mostly by the work around the data copy: how much data must move, what depends on it, and how long the business can tolerate being offline. The six drivers below interact, so a quote should show how each one was assessed rather than a single lump figure.
Database size and churn
Size sets how long the initial copy takes, while write churn decides how much change must be replayed during the window. A large database with a low write rate may move in one offline dump and restore, while a busy one usually needs logical replication to catch up before cutover. Ask the partner to measure both the total size and the daily change volume on the source, and to state which method each figure assumes. Initial bulk load and cutover rehearsal are one-time costs. Ongoing replication during a long parallel run adds recurring infrastructure cost.
Logical replication docsExtensions and their Windows builds
Each extension installed on the Windows server must have a matching Linux build for the same PostgreSQL major version, and some may need source compilation or replacement. Extensions that store compiled objects or depend on Windows-specific libraries add rework that is easy to underestimate. Ask for an inventory of every installed extension, its version, and whether a Linux package exists for the target major version. One-time engineering covers porting and testing; extension licenses and support contracts may recur.
Collation and encoding complexity
Windows and Linux often use different locale names, and a collation change can alter sort order, index contents and uniqueness checks. Encoding mismatches on text columns can corrupt or reject data during load. Effort rises with the number of databases, the number of indexes built on text, and any application logic that depends on sort order. Ask the partner to list collations and encodings per database, to test representative queries on both platforms, and to state how indexes will be rebuilt. This work is one-time, but it also determines whether application results stay the same.
Application connection and authentication changes
Moving servers changes host names, certificates and the authentication path. Windows integrated login through SSPI may need to be replaced by GSSAPI, Kerberos or a password or certificate method on Linux, and pg_hba.conf rules must be rewritten. Every application, batch job and reporting tool that connects needs its connection string and credentials checked. Ask for a list of connecting clients and their auth methods, and confirm who updates each client and who tests it. Most of this effort is one-time, though credential rotation and certificate renewal recur.
Downtime window and cutover rehearsals
The acceptable outage sets the method. An offline dump and restore needs the whole window for the copy, while logical replication shortens the final switch but requires a longer parallel run and careful sequence handling. Each rehearsal on a copy of production costs environment time and staff hours, and most projects need more than one. Ask the partner to state the expected downtime for each option, how many rehearsals are included, and what rollback looks like if cutover fails. Rehearsal effort is one-time, while a rollback standby may run for a period after cutover.
Dependent systems and reporting
Every system that reads from or writes to the database must be inventoried, including backup jobs, monitoring agents, ETL pipelines, reporting tools and scheduled scripts. Each one may use a Windows path, a service account or a Windows-only tool that needs replacing. The count and coupling of these systems often drive more effort than the database itself. Ask for a dependency map that names the owner of each system and the test that proves it works after cutover. Mapping and testing are one-time work, but backup and monitoring replacements become recurring operational costs.
What usually goes wrong in a Windows to Linux PostgreSQL move
Why do my indexes or sort results change after moving PostgreSQL from Windows to Linux?
Sort order changes most often because the database collation differs between the two platforms, so text indexes built under one locale can return rows in a different order or miss matches on the other. Windows databases frequently use locale names such as English_United States.1252, while Linux typically uses names such as en_US.UTF-8, and the C library behind the collation differs. Prevention starts with SELECT datname, datcollate, datctype FROM pg_database; on the source, then creating the target database with an explicit collation that you have tested. Rebuild every index that depends on text after load, and run queries that order or compare strings against both servers using the same sample data. Confirm the exact collation names you can use on your target Linux distribution before you plan the load.
Why do logins fail after the move when the old server used Windows authentication?
Logins usually fail because SSPI is a Windows-only method, so the pg_hba.conf entries that rely on it have no meaning on Linux. Roles that were mapped to Windows accounts, or clients that expected Kerberos through SSPI, need a different method on the new server. Review every line of the source pg_hba.conf and list each method in use, then choose a replacement from the methods PostgreSQL documents, such as GSSAPI with a Kerberos realm, LDAP, certificate or SCRAM password authentication. Check that the new method is supported by your directory and that each application connection string still matches. Test each application account against the Linux server before cutover, and confirm the password hashing method, since MD5 password authentication is deprecated in favor of SCRAM.
What breaks in scripts and services when paths and service names change?
Scheduled jobs, backup scripts and monitoring checks often hard-code Windows paths such as drive letters, backslash separators, the Windows service name and .exe file names, and these fail silently on Linux. Commands that call pg_ctl, psql or pg_dump by full path will not resolve, and a backup job that reports success on an empty output path is a common cause of a false sense of safety. Prevention is an inventory of every script, scheduled task and monitoring check that touches the server, with each path rewritten for Linux and each service managed by systemd or the package's own unit. Keep configuration values such as data_directory and archive_command in one place, and run each job once against the new server and inspect its output before relying on it.
Why are sequences or large objects missing or out of step after the load?
Data loads can leave sequences at their starting values, which causes duplicate key errors as soon as applications insert new rows. Large objects, which are stored outside ordinary columns, also need explicit handling in the dump and do not always follow a simple table copy. Logical replication does not copy sequence values, so the sequence state needs its own step at cutover. Prevention includes listing every sequence and large object on the source, comparing the current value of each sequence with the maximum key in its table, and setting each sequence past the highest value in use after the final sync. Test large object reads and writes on the target as part of acceptance, and confirm the dump options you used actually include them.
What happens if the rollback plan has never been tested?
An untested rollback usually fails at the moment it is needed, because the reverse path depends on data, roles and replication settings that nobody has exercised. A rollback from Linux to Windows is a second cross-platform move, so it carries the same collation, authentication and sequence risks as the forward move, and a physical copy will not work in either direction. Prevention is a written rollback procedure with named owners, a rehearsal on a copy of production that measures how long the reverse path takes, and a decision point after which the source is no longer the fallback. Keep the Windows source running in a read-only state until the agreed exit criteria are met, and record which writes would be lost if you switch back.
How do I check the source encoding and locale before I choose the target settings?
The encoding and locale of the source database decide whether text loads without conversion errors, so they must be confirmed before the target database is created. Run SHOW server_encoding; and check datcollate and datctype for each database, then compare them with the locale files that exist on your Linux image. If the source uses a single-byte Windows code page for some data, plan a conversion step and test characters outside basic Latin, including accented names and symbols that users type into applications. Record each check as an acceptance item so that the target configuration is documented, not inferred from defaults.
How much does a Windows to Linux PostgreSQL move cost, and what drives it?
No supplied source gives a fixed cost or duration for this move, so the figure depends on the work you can see in your own environment. The main cost drivers are the number of databases and the total data volume, how many applications and scripts depend on Windows-specific behavior, whether the move needs logical replication or an offline dump, and how many rehearsals the rollback test requires. Costs are both one-time (inventory, conversion, rehearsals, cutover) and recurring (running the new platform, backups and monitoring). DeployOpen works from a written scope, so ask for the inventory of databases, scripts, authentication rules and acceptance criteria to be reflected in the quote.
How data moves from the Windows source to the Linux target
The diagram starts at the Windows PostgreSQL server, which stays live as the source of truth. Data reaches the Linux target through one of two paths: logical replication, which streams changes between major versions and platforms, or a dump and restore. Before cutover, the team checks collation and encoding on the target, runs a parallel period, and keeps the Windows server available as a rollback path.
Two transfer paths feed the Linux target, with checks before cutover and a retained rollback path.
How DeployOpen scopes and delivers a Windows to Linux PostgreSQL move
DeployOpen plans, implements, tests, documents and supports self-hosted open-source platforms inside your own infrastructure, so a Windows to Linux PostgreSQL move is scoped against your databases, your recovery targets and your cutover window before any work starts. Engagements are fixed-scope, with scope, deliverables and timelines agreed in writing first.
How we scope
- Inventory every PostgreSQL cluster, database, extension, role and collation setting on the Windows servers in scope.
- Agree in writing which migration method applies to each database, such as dump and restore or logical replication.
- Define the cutover window, acceptable downtime, rollback point and who approves go-live before build begins.
How we build
- Provision the Linux target with the same major version as the source, then verify encoding, locale and collation settings match.
- Run test loads of each database, comparing row counts, checksums and sequence values against the Windows source.
- Rehearse the full cutover at least once, timing each step and recording the rollback procedure with its checkpoints.
How we hand over
- Deliver the runbook, connection string changes, configuration files and a record of every collation and encoding check.
- Document the validation results, including any objects that were rewritten or excluded from the move.
- Walk your database, operations and security teams through the Linux server layout, backup jobs and restore tests.
How we support
- Offer post-cutover support for a defined period, covering monitoring setup, first backup verification and issue triage.
- Provide ongoing support, upgrades and continuous testing as a retainer after handover, if your team needs it.
- Confirm with us during scoping which support terms and retainer options apply to your environment.

