I have a website with Postgres DB. Site was created in 2017, So I am updating it to latest versions of all technologies. I have created another server and plan to move this entire site on new server, but I need to test each component. My site code I can directly upload from my computer to new server.
However is there a way to take dump of Postgres directly to new server? I want to take dump of Postgres directly to new server because current server has only 50 GB space and my DB is of 35GB, so backup will fail due to space constraint.
Will this code work? I do not want to take any risk with live database.
pg_dump -C -h local -U localuser source_database | psql -h remote -U remoteuser target_database
Got this from internet. So my purpose in short is: Take backup of database to restore in another server. But do not save file in old server, transfer to new server. Sorry if I sound idiotic. Have learnt 80% of things from SO.