Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding "--clean", "--if-exists" for pgrestore #70

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/m2ee.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@
import subprocess
import sys
import yaml
import os.path

from m2ee import pgutil, M2EE, client_errno
import m2ee

logger = logging

if not sys.stdout.isatty():
if not sys.stdout.isatty() and not os.path.basename(__file__) == "m2ee-pipe":
import codecs
import locale
sys.stdout = codecs.getwriter(locale.getpreferredencoding())(sys.stdout)
Expand Down
2 changes: 1 addition & 1 deletion src/m2ee/pgutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def restoredb(config, dump_name):
)
logger.debug("Restoring %s" % db_dump_file_name)
cmd = (config.get_pg_restore_binary(), "-d", env['PGDATABASE'],
"-O", "-n", default_schema, "-x", db_dump_file_name)
"--clean", "--if-exists", "-O", "-n", default_schema, "-x", db_dump_file_name)
logger.trace("Executing %s" % str(cmd))
try:
proc = subprocess.Popen(cmd, env=env, stdout=subprocess.PIPE,
Expand Down