|
117 | 117 |
|
118 | 118 | echo "${YELLOW}Dumping source database data from '$SOURCE_URL' to '$OUTPUT'...${RESET}"
|
119 | 119 | # clean (drop) database objects before creation but only if exists
|
120 |
| -# no owner, no grant privileges, includes blobs, use directory format, jobs for parallel tasks |
121 |
| -pg_dump -v --clean --if-exists --no-owner --no-privileges --blobs --format d --jobs "$JOBS" -f "$OUTPUT" "$SOURCE_URL" |
| 120 | +# no owner, no grant privileges, no comment extensions, includes blobs, use directory format, jobs for parallel tasks |
| 121 | +pg_dump -v --clean --if-exists --no-owner --no-privileges --no-comments --blobs --format d --jobs "$JOBS" -f "$OUTPUT" "$SOURCE_URL" |
122 | 122 |
|
123 | 123 | if ! [ "$?" == "0" ]
|
124 | 124 | then
|
|
129 | 129 | echo "${GREEN}Source database dump to '$OUTPUT' successful.${RESET}"
|
130 | 130 | echo "${YELLOW}Restoring target database with data from '$OUTPUT' to '$TARGET_URL'...${RESET}"
|
131 | 131 |
|
132 |
| -# creates database before restore, no ownership, use directory format, jobs for parallel tasks |
133 |
| -pg_restore -v --clean --if-exists --no-owner --no-privileges --jobs "$JOBS" --dbname "$TARGET_URL" "$OUTPUT" |
| 132 | +# creates database before restore, no ownership, no privileges, only restore public schema and analytics, use directory format, jobs for parallel tasks |
| 133 | +pg_restore -v --clean --if-exists --no-owner --no-privileges -n public -n analytics --jobs "$JOBS" --dbname "$TARGET_URL" "$OUTPUT" |
134 | 134 |
|
135 |
| -if ! [ "$?" == "0" ] |
| 135 | +EXIT_CODE=$? |
| 136 | +if [ "$EXIT_CODE" == "0" ] |
136 | 137 | then
|
| 138 | + echo "${GREEN}Target database restore from '$OUTPUT' successful.${RESET}" |
| 139 | + echo "${GREEN}Database migration complete!${RESET}" |
| 140 | +else |
137 | 141 | echo "${RED}Database restore failure, stopping migration.${RESET}"
|
138 |
| - exit 1 |
139 | 142 | fi
|
140 | 143 |
|
141 |
| -echo "${GREEN}Target database restore from '$OUTPUT' successful.${RESET}" |
142 |
| -echo "${GREEN}Database migration complete!${RESET}" |
| 144 | +echo "${YELLOW}Deleting temporary data folder '$OUTPUT'.${RESET}" |
| 145 | +rm -R "$OUTPUT" |
| 146 | +echo "${GREEN}Temporary data folder '$OUTPUT' deleted.${RESET}" |
| 147 | +exit $EXIT_CODE |
0 commit comments