Skip to content

Commit

Permalink
Fix 'pg_restore: error: one of -d/--dbname and -f/--file must be spec…
Browse files Browse the repository at this point in the history
…ified' - closes #1867
  • Loading branch information
JedMeister committed Nov 6, 2023
1 parent 31f6f30 commit aa8954d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pgsql.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ def dumpdb(outdir, name, tlimits=[]):

def restoredb(dbdump, dbname, tlimits=[]):
manifest = file(join(dbdump, FNAME_MANIFEST)).read().splitlines()

# remove any malformed entries
manifest = [i for i in manifest if not i.endswith('Permission denied')]
try:
getoutput(su("dropdb " + dbname))
except:
Expand All @@ -69,13 +70,13 @@ def restoredb(dbdump, dbname, tlimits=[]):

try:
command = "tar c %s 2>/dev/null" % " ".join(manifest)
command += " | pg_restore --create --format=tar"
command += " | pg_restore --create --dbname=postgres --format=tar"
for (table, sign) in tlimits:
if sign:
command += " --table=" + table
command += " | " + su("cd $HOME; psql")
system(command)

finally:
os.chdir(orig_cwd)

Expand Down

0 comments on commit aa8954d

Please sign in to comment.