June 12, 2020

Postgres backup and restore a database

Postgres backup and restore a database

In some cases is useful to load production data on development environments to check some data bugs, then you need create backups and import on others machine ( or database )  to be used

You can achieve with two simple commands

-- Backup
pg_dump -U {user} {database_name} -f {dumpfilename.sql} -h {host}
-- Restore
psql -U {user} -d {database_name} -h {host} -f {dumpfilename.sql}