Move postgresql data directory to a new location

Keywords: PostgreSQL - Virtual Machines - How to - Other
Description:
Hi,

I’ve just created my Bitnami postgresql azure server (Bitnami PostgreSQL 10.5-0). I follow this tutorial to move the data directory to a new location:

https://www.digitalocean.com/community/tutorials/how-to-move-a-postgresql-data-directory-to-a-new-location-on-ubuntu-16-04

But when I use the command:
sudo systemctl stop postgresql

I get the following message:
Failed to stop postgresql.service: Unit postgresql.service not loaded.

I searched everywhere in the internet but I did not find any thing helpful.

Could you give me some instruction on how to move data directory for Bitnami postgres?

Thanks

Hi @lnthanh.im,

Thanks for using Bitnami. In a Bitnami installation, to stop / start the PostgreSQL server use:

  • sudo /opt/bitnami/ctlscript.sh stop postgresql
  • sudo /opt/bitnami/ctlscript.sh start postgresql

The data and configuration directory is in /opt/bitnami/postgresql/data. Given that the scripts etc expect that location, my recommendation would be:

  1. Take a backup
  2. Stop the service.
  3. Move the data folder to the new location.
    4 Create a symbolic link in named /opt/bitnami/postgresql/data to the new location.
    5 Start the service.

Regards,

Andres R.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.