Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1T651l-0006PT-KE for pgsql-bugs@postgresql.org; Mon, 27 Aug 2012 19:31:13 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1T651i-0008GY-Ti for pgsql-bugs@postgresql.org; Mon, 27 Aug 2012 19:31:13 +0000 Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.5/8.14.5) with ESMTP id q7RJV8f0007537; Mon, 27 Aug 2012 15:31:08 -0400 (EDT) From: Tom Lane To: iann@fuelforce.com cc: pgsql-bugs@postgresql.org Subject: Re: BUG #7507: pg_restore silently fails when restoring a db with the --create flag and no user. In-reply-to: References: Comments: In-reply-to iann@fuelforce.com message dated "Mon, 27 Aug 2012 15:34:10 -0000" Date: Mon, 27 Aug 2012 15:31:08 -0400 Message-ID: <7536.1346095868@sss.pgh.pa.us> X-Pg-Spam-Score: -2.1 (--) X-Archive-Number: 201208/206 X-Sequence-Number: 33930 iann@fuelforce.com writes: > Attempting to restore a db using pg_restore to a new database server using > the --create and --dbname flags fails silently if the db owner username does > not exist in the new db or the -O flag is not used. > Command used: > pg_restore --create --verbose --dbname=testserver > /Volumes/USBLINKS1/hostname.testserver.net_postgres_database It'll fail, yes, because pg_dump by itself doesn't dump CREATE USER commands (since users are external to any individual database). However, it hardly seems "silent" to me. I see complaints like these: pg_restore: [archiver (db)] Error while PROCESSING TOC: pg_restore: [archiver (db)] Error from TOC entry 1851; 1262 116736 DATABASE mydb dbowner pg_restore: [archiver (db)] could not execute query: ERROR: role "dbowner" does not exist Command was: ALTER DATABASE mydb OWNER TO dbowner; pg_restore: [archiver (db)] Error from TOC entry 161; 1259 116737 TABLE mytable dbowner pg_restore: [archiver (db)] could not execute query: ERROR: role "dbowner" does not exist Command was: ALTER TABLE public.mytable OWNER TO dbowner; WARNING: errors ignored on restore: 2 Possibly you want to use the --exit-on-error option? regards, tom lane