Postgres backup and restore
Jul 27, 2021
Take a dump of the local database:
pg_dump -U postgres -h localhost mydb > db_28_07_2021.sql
Copy file from one server to another server remotely
scp <source> <destination>
scp <username>@<Public IP>:/home/ubuntu/dbbackup/db_28_07_2021.sql /home/local/mylocalsystem/
Restore the data in local database
sudo su postgres
psql database_name < /home/local/mylocalsystem/db_28_07_2021.sql
Restore the data in remore database
psql -h myhost.rds.amazonaws.com -U postgres -d database_name < /home/local/mylocalsystem/db_28_07_2021.sql