postgresqldatabase-backupsdatabase-restorepgadmin-4postgres-10

How do you create a database from a backup with PostgreSQL?


In SQL Server, I can create a new database on the server from a backup from another box. I can't seem to find that functionality in pgAdmin4 with PostgreSQL10. It seems like all I can do is restore an existing database. Do I need to just create a blank database first?


Solution

  • You can use --create or -C in pg_dump function to make database. From Documentation :

    Begin the output with a command to create the database itself and reconnect to the created database. (With a script of this form, it doesn't matter which database in the destination installation you connect to before running the script.)

    For syntax :

    pg_dump -C -U your_user -d your_db > filename.sql
    

    or

    pg_dump --create -U your_user -d your_db > filename.sql