File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11#!/usr/bin/env python
22
33"""A simple module to recover a backup created with pg_dumpall (or pg_dump)
4- (as performed by our sql-backup container).
4+ (as performed by our sql-backup container). Importantly,
5+ any pg_dumpall backup is expected to have been created with
6+ "--clean" and "-if-exists" options.
57
68The backup directory (BACKUP_ROOT_DIR) is expected to have
79been mounted as a volume in the container image.
@@ -550,7 +552,7 @@ def error(error_no):
550552# We only need to do this if the recovery is from a dumpall.
551553if not DATABASE :
552554 TARGET_FILE = "%s/%s.sql" % (RECOVERY_ROOT_DIR , DECOMPRESSED_RECOVERY_NAME )
553- FILTER_PG_CMD = "egrep -v '^(CREATE|DROP) ROLE %s;' %s > filtered.sql ; mv filtered.sql %s" % (RECOVERY_DATABASE_ROOT_USER , TARGET_FILE , TARGET_FILE )
555+ FILTER_PG_CMD = "egrep -v '^(CREATE|DROP) ROLE IF EXISTS %s;' %s > filtered.sql ; mv filtered.sql %s" % (RECOVERY_DATABASE_ROOT_USER , TARGET_FILE , TARGET_FILE )
554556 print (" $" , FILTER_PG_CMD )
555557 COMPLETED_PROCESS = subprocess .run (FILTER_PG_CMD ,
556558 shell = True ,
You can’t perform that action at this time.
0 commit comments