- On the source server(remote/local), export the backup first:
pg_dump -U {username} -h {host} -p {port} -f {output-file-path}.sql {dbname to backup}
copy the backup file to the target server.
- On the target server(remote/local), log into the postgres using below command.
psql -h [HOST-STRING] -d [DATABASE-NAME] -U [USERNAME]
- Select the database with same name as you exported from source or create new if not available:
CREATE DATABASE {dbname};
\c {dbname};
- Import the backup file
\i {backup-file-path};