Skip to content

Commit aa8954d

Browse files
committed
Fix 'pg_restore: error: one of -d/--dbname and -f/--file must be specified' - closes #1867
1 parent 31f6f30 commit aa8954d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

pgsql.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ def dumpdb(outdir, name, tlimits=[]):
5858

5959
def restoredb(dbdump, dbname, tlimits=[]):
6060
manifest = file(join(dbdump, FNAME_MANIFEST)).read().splitlines()
61-
61+
# remove any malformed entries
62+
manifest = [i for i in manifest if not i.endswith('Permission denied')]
6263
try:
6364
getoutput(su("dropdb " + dbname))
6465
except:
@@ -69,13 +70,13 @@ def restoredb(dbdump, dbname, tlimits=[]):
6970

7071
try:
7172
command = "tar c %s 2>/dev/null" % " ".join(manifest)
72-
command += " | pg_restore --create --format=tar"
73+
command += " | pg_restore --create --dbname=postgres --format=tar"
7374
for (table, sign) in tlimits:
7475
if sign:
7576
command += " --table=" + table
7677
command += " | " + su("cd $HOME; psql")
7778
system(command)
78-
79+
7980
finally:
8081
os.chdir(orig_cwd)
8182

0 commit comments

Comments
 (0)