PostgreSQL migration

We want to change the data directory of PostgreSQL 10 from disk C to D and tried a few methods found on the internet (e.g., How to Migrate your PostgreSQL Data Directory in Windows) but failed. Can someone give some instructions? Our server is Windows Server 2016 (14393.4046) and PostgreSQL 10.5. Survey Solutions is 20.10.3.29613.

Thank you!

Hello @PPP ,

you wrote “We … tried a few methods found on the internet… but failed”.
Could you please explain what specifically was the problem after following the instructions? (at which step? what error message?)

Best, Sergiy

Hi Sergiy! Thank you for your reply! The problem is simply nothing changes. When we restart the service, the original data folder (on C:) continued being modified and the new folder (on D:) did not change.

Well, the official (and ages old) guidance on this is in the PostgreSQL Wiki:
https://wiki.postgresql.org/wiki/Change_the_default_PGDATA_directory_on_Windows

The video is here:

(Both are not by me)

So make sure you stop Survey Solutions, make a backup of your DB, properly copy it to a safe place, and then proceed step by step carefully.

Hi Sergiy! Thank you for the reference! I just came back from a field trip and tried these methods. Neither worked. Can I uninstall PostgreSQL 10.5-1 Server (current version) and reinstall it or install another version of PostgreSQL (say, 13) then import the old data from the new location? Thank you!