Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in AWS by (19.1k points)

We've been running postgresql 8.4 for quite some time. As with any database, we are slowly reaching our threshold for space. I added another 8 GB EBS drive and mounted it to our instance and configured it to work properly on a directory called /files

Within /files, I manually created

Correct me if I'm wrong, but I believe all postgresql data is stored in /var/lib/postgresql/8.4/main

I backed up the database and I ran sudo /etc/init.d/postgresql stop. This stops the postgresql server. I tried to copy and paste the contents of /var/lib/postgresql/8.4/main into the /files directory but that turned out be a HUGE MESS! due to file permissions. I had to go in and chmod the contents of that folder just so that I could copy and paste them. Some files did not copy fully because of root permissions. I modified the data_directory parameter in postgresql.conf to point to the files directory

 data_directory = '/files/postgresql/main'

and I ran sudo /etc/init.d/postgresql restart and the server failed to start. Again probably due to permission issues. Amazon EC2 only allows you to access the service as ubuntu by default. You can only access root from within the terminal which makes everything a lot more complicated.

Is there a much cleaner and more efficient step by step way of doing this?

1 Answer

0 votes
by (44.4k points)

First, stop the running server

Then copy the data directory (datadir) while retaining permissions:

cp -aRv

Rename you old datadir and keep it aside. Now, symlink the old path to the new location.

Related questions

0 votes
1 answer
Want to get 50% Hike on your Salary?

Learn how we helped 50,000+ professionals like you !

0 votes
1 answer
0 votes
1 answer
asked Jul 5, 2019 in AWS by yuvraj (19.1k points)
+1 vote
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...