For example, there is a postgres user, base and trust access.
To save a database cluster:
pg_dumpall -U postgres -w > backup
To restore a database cluster:
psql -U postgres -w -f backup postgres
Backup base:
pg_dump -v -h 127.0.0.0 -F c -U postgres -W -f "base.backup" base
Source: https://ru.stackoverflow.com/questions/3/