Changing PostgreSQL Data Folder (expert users)
Local installations of Flow Production Tracking are no longer offered. This documentation is intended only for those with existing instances of Shotgun Enterprise Docker. Click here for a list of our current offerings.
Assumptions
- The Postgresql version is 15
1. Create the new data folder
First, create the folder in which you want to store the PostgreSQL database.
sudo mkdir /postgres
sudo chown postgres:postgres /postgresThen, stop the PostgreSQL, if running.
sudo service postgresql-15 stop2. Change the folder by copying the old data folder
If you want to copy the existing data folder to a new location, rsync the data to the new location. Skip the rsync if you want to initialize a new data folder. Make sure to omit the trailing slashes for rsync to properly mimic the original directory structure in the destination, including permissions and ownership.
sudo rsync -av /var/lib/pgsql/15 /postgres 3. Change the data folder used by PostgreSQL when starting
Customize the systemd configuration for PostgreSQL in order to override the PGDATA folder.
sudo vi /etc/systemd/system/postgresql-15.serviceInsert the following.
# Include the default config:
.include /usr/lib/systemd/system/postgresql-15.service
[Service]
Environment=PGDATA=/postgresReload the systemd daemon.
sudo systemctl daemon-reload4. Initialize an empty data folder
If you didn’t copy a previous data folder, the new data folder needs to be initialized. First, edit the bootstrap script to set the new PGDATA folder.
vi postgres_bootstrap_centos7.shEdit PGDATA
export PGDATA=/postgresRe-run the PostgreSQL bootstrap script
bash postgres_bootstrap_centos7.shPostgreSQL should start using the new folder
ps aux | grep postgres
