Deleting Old Files in PostgreSQL After Changing Data Directory

postgresqlpostgresql-9.3

Very recently, I changed the data_directory of posgresql (9.3.10) to point to a new data disk I recently added to my VM (Ubuntu 14.04 OS). All the old data has been transferred to this new disk as well.

Prior to this shift, the data_directory was residing in the disk that had the OS installed too. This was a digestible arrangement initially, but ultimately the data_directory almost came to fill the entire 30GB space available. Thus I made the shift.

My question is: can I delete the contents of the old var/lib/postgresql/9.x/main/ folder now that data_directory is entirely pointing to a new location?

The old files are still intact, taking a ton of space, and the only reason I haven't deleted them is because other elements in the postgresql config (or some daemon scripts) might be referring to this folder structure somehow. I'm not sure. Someone with experience can perhaps help out here.

Best Answer

There shouldn't be any references as all the scripts/utils/etc use the data directory environment variable.

the only place I would look is in the new configuration file - take a look you don't have any includes that point to the old folder (not sure at what version they added this option.)

BTW, it's always a good practice to rename (mv dir dir_bck) the folder for a week to see you really don't have anything trying to access there. (you shouldn't anyway as it's stale data...)

Regards,
- Jony