Steps to change the PostgreSQL's data storage location

KB ID : 115042
Published : May 11, 2017
Created : May 11, 2017
Last Modified : May 11, 2017

Challenge

Migrating Vembu BDR internal database(PostgreSQL) files from one location to another location.

Cause

Storage space of PostgreSQL database increase when there is an increase in backup data size in Vembu BDR server.

Solution

Follow steps given below to migrate PostgreSQL data:

For Windows

Step 1: Open PostgreSQL in command prompt and execute following command to find the current data directory path “show data_directory;”

image description

Step 2: Stop VembuBDR and PostgreSQL services in services.msc

Step 3: Copy data directory from old location(Path Found in Step 1) to new location.

Step 4: Ensure the newly created folder has all permissions for local system user.

Step 5: Open Windows Registry editor and go to below path:

“HKEYLOCALMACHINE\SYSTEM\CurrentControlSet\Services\postgresql”

Edit ‘ImagePath’ value and change default path of data directory to new location (which comes after -D in value).

image description

Step 6: Start PostgreSQL service and ensure new data location is updated by repeating Step 1.

Step 7: Once new location is updated successfully, start Vembu BDR service to resume backup/replication tasks.

For Ubuntu

Step 1: Start an interactive PostgreSQL session and execute the following command to find current data directory path: “show data_directory;”

image description

Step 2: Stop VembuBDR and PostgreSQL services using below command:

  • /etc/init.d/postgresql stop
  • /etc/init.d/vembubdr stop

Step 3: Move data directory from old location(Path Found in Step 1) to new location.

Step 4: Open ‘postgresql.conf’ file and update ‘data_directory’ value with new path location.

Ex: By default, configuration file can be found in following location: /etc/postgresql/9.6/main/postgresql.conf

image description

Step 5: Start PostgreSQL service by executing following command: /etc/init.d/postgresql start

Step 6: Ensure new data location is updated successfully by repeating Step 1.

Step 7: Once new location is updated successfully, start Vembu BDR service to resume backup/replication tasks.

edit retag flag offensive close merge delete