

Hba_file = '/etc/postgresql/9.5/main/pg_hba.conf' # host-based authentication file # option or PGDATA environment variable, represented here as ConfigDirĭata_directory = '/mnt/data_vol/postgresql/9.5/main' # use data in another directory # The default values of these variables are driven from the -D command-line We can change the default data folder by editing the /etc/postgresql/9.5/main/nf file and edit the data_directory. $ sudo mv /var/lib/postgresql/9.5/main /var/lib/postgresql_backup Changing the Data folder Location on Postgresql Configuration Files Once the database is copied we will rename the old data folder and we will keep this folder till we confirm the changes in later steps so that we cannot lose the data from the machine. Postgresql/9.5/main/pg_xlog/archive_status/ Postgresql/9.5/main/global/pg_filenode.map $ sudo rsync -av /var/lib/postgresql /mnt/data_vol/ Using rsync, we will create a new postgresql folder at new location here the new location means new mounted volume with data_vol at /mnt/data_vol and the permissions are retained with PostgreSQL so that we cannot get any permission issues while copying the files to the new location.īelow is the command to copy the data. Moving the Existing PostgreSQL data to the New LocationĪs we stopped the data we will now move the existing PostgreSQL data to the new location with rysnc command with -a and –v flags, -a preserves the files and folder permission at the new location and –v will display the verbose output. Sep 12 15:20:23 ubuntu-16 systemd: Stopped PostgreSQL RDBMS. Sep 07 19:27:27 ubuntu-16 systemd: Started PostgreSQL RDBMS. Sep 07 19:27:27 ubuntu-16 systemd: Starting PostgreSQL RDBMS. Main PID: 1553 (code=exited, status=0/SUCCESS) Process: 1553 ExecStart=/bin/true (code=exited, status=0/SUCCESS) Loaded: loaded (/lib/systemd/system/rvice enabled vendor preseĪctive: inactive (dead) since Mon 15:40:23 IST 3s ago Once we stop the PostgreSQL we will check the status of the PostgreSQL services with the below command $ sudo systemctl status postgresql Now, we will stop the PostgreSQL service to change the default location for the data folderīelow is the command to stop the PostgreSQL services. With the above command, we will come to know that the default data directory location is /var/lib/postgresql/9.5/main To verify the current data location settings on the server postgres=# SHOW data_directory Below is the command to verify the current data location settings on the server.
#Postgres app data directory how to
If you require any help at all with your PostgreSQL database, then feel free to review our Support services, customized Training, or Health Check Assessment.In this article, we will learn how to change or relocate the PostgreSQL Database data directory to the new location on Ubuntu 16.04. This will be the subject of another post. The files that have a number and have _fsm or _vm appended are the free space map and the visibility map for each page. If you want to encrypt the data in the files on disk you can use the FUJITSU Enterprise Postgres transparent data encryption feature that I have described here.


You might consider this visibility on disk to be a problem. My inserted varchar string, 'hello there' is now stored and visible on my disk. SELECT pg_relation_filepath('test_table') SELECT oid as object_id, datname as database_name FROM pg_database where datname ='test'
