Tuesday, April 13, 2010

Disk full : Moving a Postgresql database data folder

For testing purposes, I set up a Postgresql 8.3 database on a Windows machine. The hard drive space was too little for the use, so I had to move the data folder to another location. (I could not use the saving mechanisms because the remaining space was not big enough even for the temporary files required for the operation.)

This proved to be quite easy. However, you cannot keep the database running.
  1. You first stop the database service from the Windows from the Computer Management console,
  2. Then move the data folder to a new location with more space,
  3. Then modify the path in the config file postmaster.opts, in the data folder itself,
  4. Then modify the path that's given to the service when it's launched by Windows : in the registry, edit the ImagePath string at key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\pgsql-8.3
  5. Then restart the database service from the Computer Management console.