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

Use pg-restore to restore directory one file dump #69

Merged
merged 11 commits into from
Jul 29, 2018
Merged

Conversation

dmius
Copy link
Collaborator

@dmius dmius commented Jul 24, 2018

No description provided.

@dmius dmius requested a review from NikolayS July 24, 2018 21:26
checkPath AFTER_DOCKER_INIT_CODE
if [ "$?" -ne "0" ]; then
#>&2 echo "WARNING: Value given as after_db_init_code: '$AFTER_DOCKER_INIT_CODE' not found as file will use as content"
echo "$AFTER_DOCKER_INIT_CODE" > $TMP_PATH/after_docker_init_code_tmp.sh
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Можно было бы проще, без записи в файл — eval

echo "$AFTER_DOCKER_INIT_CODE" > $TMP_PATH/after_docker_init_code_tmp.sh
AFTER_DOCKER_INIT_CODE="$TMP_PATH/after_docker_init_code_tmp.sh"
else
[ "$DEBUG" -eq "1" ] && echo "DEBUG: Value given as commands-after-docker-init will use as filename"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Можешь обьяснить смысл сообщения? Не уверен, что правильно понял, зачем оно

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Сообщение выводится только если включен режим отладки.

@@ -641,6 +655,7 @@ function cleanupAndExit {
echo "$(date "+%Y-%m-%d %H:%M:%S"): Remove temp files..." # if exists
docker $dockerConfig exec -i ${containerHash} sh -c "sudo rm -rf $MACHINE_HOME"
rm -f "$TMP_PATH/after_db_init_code_tmp.sql"
rm -f "$TMP_PATH/after_docker_init_code_tmp.sh"
Copy link
Collaborator

@NikolayS NikolayS Jul 27, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Я думаю, что раз мы там плодим файлы, лучше удалять всю поддиректорию, только убедиться что имя уникальное

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*всю

docker_exec bash -c "chmod +x $MACHINE_HOME/$AFTER_DOCKER_INIT_CODE_FILENAME"
docker_exec sh $MACHINE_HOME/$AFTER_DOCKER_INIT_CODE_FILENAME
END_TIME=$(date +%s);
DURATION=$(echo $((END_TIME-OP_START_TIME)) | awk '{printf "%d:%02d:%02d", $1/3600, ($1/60)%60, $1%60}')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Заглавными буквами предполагалось именовать глобальные константы. А тут обычная переменная.

@@ -854,6 +882,8 @@ then
fi
OP_START_TIME=$(date +%s);
echo "$(date "+%Y-%m-%d %H:%M:%S"): Restore database dump"
#CPU_CNT=$(cat /proc/cpuinfo | grep processor | wc -l)
CPU_CNT=$(docker_exec bash -c "cat /proc/cpuinfo | grep processor | wc -l") # for execute in docker
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Да уж, это было совсем неправильно раньше :)

Copy link
Collaborator

@NikolayS NikolayS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Всё ок, несколько комментариев по стилю только, критичного ничего.

@@ -755,6 +764,8 @@ elif [[ "$RUN_ON" = "aws" ]]; then
exit 1;
fi
echo "$(date "+%Y-%m-%d %H:%M:%S"): Docker $DOCKER_MACHINE is running."
echo " To connect docker machine use:"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

хорошая идея :)

@NikolayS NikolayS merged commit b0096bf into master Jul 29, 2018
@NikolayS NikolayS deleted the dmius-pg-restore branch July 29, 2018 20:32
NikolayS added a commit that referenced this pull request Sep 18, 2018
Use pg-restore to restore directory one file dump
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants