Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

16
  • 6
    IME you practically always want to restore into a database that has been newly-created from template0. Otherwise if you've done something like activating plpgsql in template1, the restore process will try to do it again, and the -1 switch you suggest means the whole transaction will fail. So something like "createdb -T template0 seo2" followed by "pg_restore -v -d seo2 seo.pg" to restore seo.pg (made from the seo database) into a new seo2 database. If your backup file is just a .sql file, you can trim conflicting bits of it out by hand. Commented Apr 28, 2010 at 19:37
  • 75
    You cannot have -d and -f at the same time. pg_restore: options -d/--dbname and -f/--file cannot be used together Commented Feb 9, 2013 at 0:37
  • 10
    In version 9.2 the "-f" option specifies an output file, not the dump file (and it probably means the same in earlier versions). Commented Apr 6, 2014 at 12:58
  • 5
    Regarding cannot be used together, see here: stackoverflow.com/questions/27882070/… Commented Mar 23, 2016 at 20:15
  • 3
    @Alex78191 it means it executes as a single transaction, which could completely fail and rollback, or go through. It will block some access to the database also. Commented Aug 24, 2018 at 9:36