https://postgrespro.ru/docs/postgresql/9.6/backup-dump
https://www.youtube.com/watch?v=Jvdtx-Smffo
If Access Denied: Write into directory where postgres user has write access. For instance /tmp. $ sudo su - postgres $ pg_dump -h localhost mydb >/tmp/tempfile