Postgres provides us several options to do backup just like we want. I’ve tried several strategies in the past, and here is the one I stick to now, for both its simplicity and efficiency.
Backup your database with:
# This is using Postgres custom format
pg_dump -Fc dbname > filename