# - bof - # # - - # # - Move PostgreSQL Database - # # tilix # ssh uServer # :1 # - - # # - Login postgresql, data_directory - # # :1.1 # - - # # - Login postgresql - Client terminal - # sudo -u postgres psql; sudo -u cvandemberg psql -d postgres -h 192.168.0.100; sudo -u cvandemberg psql -d postgres -h www.acecom.one; psql -U postgres -d postgres -h www.acecom.one; sudo -u is_derayo psql -d postgres -h 192.168.1.100; sudo -u is_derayo psql -d postgres -h 192.168.1.200; sudo -u is_derayo psql -d postgres -h www.isdevelopment.us; psql -U postgres -d postgres -h www.isdevelopment.us; # :1.2 # - - # # - data_directory - ## SHOW data_directory; data_directory ----------------------------- /var/lib/postgresql/14/main (1 row) \q # :2 # - - # # - Stop database & check status - # systemctl status postgresql@16-main.service; sudo systemctl stop postgresql; systemctl status postgresql@16-main.service; # :3 # - - # # - Copy database & backup original - # # :3.1 # - - # # - Copy database - ## sudo rsync -av /var/lib/postgresql /Data/; sudo rsync -av /var/lib/postgresql /Data/Databases/; # :3.2 # - - # # - Backup original - ## sudo mv /var/lib/postgresql/16/main /var/lib/postgresql/16/main.bak; # :4 # - - # # - Open postgresql.conf, Change data_directory & Owner on postgresql.conf - # # :4.1 # - - # # - Open postgresql.conf - ## sudo vim /etc/postgresql/16/main/postgresql.conf # :4.2 # - - # # - Change data_directory - ## #data_directory = '/var/lib/postgresql/16/main' # Data in another directory data_directory = '/Data/postgresql/16/main' data_directory = '/Data/Databases/postgresql/16/main' # :4.3 # - - # # - Owner on postgresql.conf - ## ls -lah /etc/postgresql/16/main; # - If changes in ownership - ## sudo chown postgres:postgres postgresql.conf ls -lah /etc/postgresql/14/main; # :5 # - - # # - Start postgresql database, Check status & Get new data_directory - # # :5.1 # - - # # - Start postgresql database, Check status - ## sudo systemctl start postgresql; systemctl status postgresql@16-main.service; # :5.2 # - - # # - Get new data_directory - ## sudo -u postgres psql; sudo -u cvandemberg psql -d postgres -h 192.168.0.100; sudo -u cvandemberg psql -d postgres -h www.acecom.one; psql -U postgres -d postgres -h www.acecom.one; sudo -u is_derayo psql -d postgres -h 192.168.1.100; sudo -u is_derayo psql -d postgres -h 192.168.1.200; sudo -u is_derayo psql -d postgres -h www.isdevelopment.us; psql -U postgres -d postgres -h www.isdevelopment.us; SHOW data_directory; data_directory -------------------------------- /Data/postgresql/14/main (1 row) \q # :6 # - - # # - Remove old data_directory, Restart postgresql & check status - # # :6.1 # - Remove old data_directory - ## sudo rm -Rf /var/lib/postgresql/16/main.bak # :6.2 # - - # # - Restart postgresql & check status - ## sudo systemctl restart postgresql; systemctl status postgresql@16-main.service; # :6.3 # - - # # - Check database new location - # ls -lah /Data; ls -lah /Data/Databases; # - eof - #