Moving the PostgreSQL Database to a New Location in Linux

From Observer GigaFlow Support | VIAVI Solutions Inc.
Jump to: navigation, search


Change /data to the folder you want to use

mkdir /data/gigaflow
systemctl stop gigaflow
systemctl stop postgresql-11
echo "rsync -av /var/lib/pgsql/11/data/ /data/gigaflow"
rsync -av /var/lib/pgsql/11/data/ /data/gigaflow
echo "mv /var/lib/pgsql/11/data /var/lib/pgsql/11/data_old"
mv /var/lib/pgsql/11/data /var/lib/pgsql/11/data_old
echo "ln -s /data/gigaflow /var/lib/pgsql/11/data"
ln -s /data/gigaflow /var/lib/pgsql/11/data
chown postgres:postgres /var/lib/pgsql/11/data
chmod 0700 /var/lib/pgsql/11/data
systemctl start postgresql-11
systemctl start gigaflow