File tree Expand file tree Collapse file tree 1 file changed +4
-7
lines changed
Expand file tree Collapse file tree 1 file changed +4
-7
lines changed Original file line number Diff line number Diff line change @@ -23,13 +23,10 @@ OLD_DEPLOYMENT=${1}
2323NEW_DEPLOYMENT=${2}
2424DUMP_FILE_PATH=/tmp/backup.dump
2525
26- # Create and copy dump from the old deployment
26+ # Create dump from the old deployment and save locally
2727OLD_POD=$( oc get po -l deployment=${OLD_DEPLOYMENT} -o name | head -n 1 | sed ' s|pod/||' )
28- oc exec -it deployment/${OLD_DEPLOYMENT} -- bash -c " pg_dump -U \$ {POSTGRES_USER} -d \$ {POSTGRES_DB} -Fc -f ${DUMP_FILE_PATH} && ls -lh ${DUMP_FILE_PATH} "
29- oc cp ${OLD_POD} :${DUMP_FILE_PATH} ${DUMP_FILE_PATH}
28+ oc exec -i deployment/${OLD_DEPLOYMENT} -- bash -c " pg_dump -U \$ {POSTGRES_USER} -d \$ {POSTGRES_DB} -Fc" > ${DUMP_FILE_PATH}
3029ls -lh ${DUMP_FILE_PATH}
3130
32- # Copy and restore dump to the new deployment
33- NEW_POD=$( oc get po -l deployment=${NEW_DEPLOYMENT} -o name | head -n 1 | sed ' s|pod/||' )
34- oc cp ${DUMP_FILE_PATH} ${NEW_POD} :${DUMP_FILE_PATH} -c fom
35- oc exec -it deployment/${NEW_DEPLOYMENT} -- bash -c " pg_restore -U \$ {POSTGRES_USER} -d \$ {POSTGRES_DB} -Fc ${DUMP_FILE_PATH} "
31+ # Stream dump into pg_restore in the new deployment (no file copy needed)
32+ oc exec -i deployment/${NEW_DEPLOYMENT} -- bash -c " pg_restore -U \$ {POSTGRES_USER} -d \$ {POSTGRES_DB} -Fc" < ${DUMP_FILE_PATH}
You can’t perform that action at this time.
0 commit comments