You have multiple ways to backup/restore Rails database with Postgres:
In simple use the following commands to backup and restore the database for PostgreSQL:
pg_dump c -v -U postgres -h localhost
Here -W is used to force to ask password.
For restore use the following command:
pg_restore -c -C -U postgres -h localhost
Here -C -c will drop the database if it exists already and then recreate it new.