Skip to content
This repository was archived by the owner on Aug 16, 2021. It is now read-only.

Commit 3da40f0

Browse files
dmiusDmitry
authored andcommitted
Use pg-restore to restore directory one file dump
1 parent 9a0975d commit 3da40f0

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

nancy_run.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,7 @@ function checkPath() {
301301
if [[ $path =~ "file:///" ]]
302302
then
303303
path=${path/file:\/\//}
304-
if [ -f $path ]
305-
then
304+
if [ -f $path ] || [ -d $path ]; then
306305
eval "$1=\"$path\"" # update original variable
307306
return 0 # file found
308307
else
@@ -313,8 +312,7 @@ function checkPath() {
313312
then
314313
curdir=$(pwd)
315314
path=$curdir/${path/file:\/\//}
316-
if [ -f $path ]
317-
then
315+
if [ -f $path ] || [ -d $path ]; then
318316
eval "$1=\"$path\"" # update original variable
319317
return 0 # file found
320318
else
@@ -408,7 +406,7 @@ function checkParams() {
408406
echo "$DB_DUMP_PATH" > $TMP_PATH/db_dump_tmp.sql
409407
DB_DUMP_PATH="$TMP_PATH/db_dump_tmp.sql"
410408
else
411-
[ "$DEBUG" -eq "1" ] && echo "DEBUG: Value given as db-dump will use as filename"
409+
[ "$DEBUG" -eq "1" ] && echo "DEBUG: Value given as db-dump will use as path"
412410
fi
413411
DB_DUMP_FILENAME=$(basename $DB_DUMP_PATH)
414412
DB_DUMP_EXT=${DB_DUMP_FILENAME##*.}
@@ -864,6 +862,9 @@ case "$DB_DUMP_EXT" in
864862
gz)
865863
docker_exec bash -c "zcat $MACHINE_HOME/$DB_DUMP_FILENAME | psql --set ON_ERROR_STOP=on -U postgres test $OUTPUT_REDIRECT"
866864
;;
865+
pgdmp)
866+
docker_exec bash -c "pg_restore -j $(cat /proc/cpuinfo | grep processor | wc -l) --no-owner --no-privileges -U postgres -d test $MACHINE_HOME/$DB_DUMP_FILENAME"
867+
;;
867868
esac
868869
END_TIME=$(date +%s);
869870
DURATION=$(echo $((END_TIME-OP_START_TIME)) | awk '{printf "%d:%02d:%02d", $1/3600, ($1/60)%60, $1%60}')

0 commit comments

Comments
 (0)