I want to move my data folder from my SSD do HDD on my Linux Mint 19.1 Cinnamon.

I have install postgresql from https://www.enterprisedb.com/downloads/postgres-postgresql-downloads version Linux x86-64 10.7. I have found this article: https://www.digitalocean.com/community/tutorials/how-to-move-a-postgresql-data-directory-to-a-new-location-on-ubuntu-18-04 and tried to follow, but I am stuck.

I have my data directory here: /opt/PostgreSQL/10/data (from psql -> SHOW data_directory) and I have my postgresql.conf in this data directory as well (/opt/PostgreSQL/10/data/postgresql.conf). I can move my data directory, but I would move conf file as well. I just cannot see, how postgresql would know new configuration if this configuration is in new location.


All right, unfortunately I was not able to achieve what I want with pgAdmin4 installation. I have installed postgresql: sudo apt install postgresql-10 After that I have my postgresql.conf here: /etc/postgresql/10/main/postgresql.conf

I have done what is in this tutorial (same as in question): https://www.digitalocean.com/community/tutorials/how-to-move-a-postgresql-data-directory-to-a-new-location-on-ubuntu-18-04

But then I got stuck again with problem answered here: https://stackoverflow.com/questions/42653690/psql-could-not-connect-to-server-no-such-file-or-directory-5432-error

So I am checking my log file postgresql-10-main.log and I see this: pgctl: could not access directory "/my/new/datadir/postgresql/10/main": Permission denied

I have added owner like this: sudo chown -R postgres /my/new/data_dir/ and added permissions like this: sudo chmod -R o=rwx /my/new/data_dir/

And after that I got really good error message again in my log file postgresql-10-main.log that said, that "/my/new/datadir/postgresql/10/main" directory has to have 0700 permissions.

After that, it finally works.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.