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

Commit 03a1603

Browse files
dmiusDmitry
authored andcommitted
Detemine dump file size
1 parent 890bd9f commit 03a1603

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

nancy_run.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ CURRENT_TS=$(date +%Y%m%d_%H%M%S%N_%Z)
55
DOCKER_MACHINE="${DOCKER_MACHINE:-nancy-$CURRENT_TS}"
66
DOCKER_MACHINE="${DOCKER_MACHINE//_/-}"
77
DEBUG_TIMEOUT=0
8+
EBS_SIZE=1 #GB
89

910
## Get command line params
1011
while true; do
@@ -473,6 +474,33 @@ function checkParams() {
473474

474475
checkParams;
475476

477+
478+
# Determine dump file size
479+
if [ ! -z ${DB_DUMP_PATH+x} ]; then
480+
dumpFileSize=0
481+
if [[ $DB_DUMP_PATH =~ "s3://" ]]; then
482+
dumpFileSize=$(s3cmd info $DB_DUMP_PATH | grep "File size:" )
483+
dumpFileSize=${dumpFileSize/File size:/}
484+
dumpFileSize=${dumpFileSize/\t/}
485+
dumpFileSize=${dumpFileSize// /}
486+
#echo "S3 FILESIZE: $dumpFileSize"
487+
else
488+
dumpFileSize=$(stat -c%s "$DB_DUMP_PATH")
489+
fi
490+
[ $DEBUG -eq 1 ] && echo "Dump filesize: $dumpFileSize bytes"
491+
KB=1024
492+
let minSize=300*$KB*$KB*$KB
493+
ebsSize=$minSize # 300 GB
494+
if [ "$dumpFileSize" -gt "$minSize" ]; then
495+
let ebsSize=$dumpFileSize
496+
fi
497+
ebsSize=$(numfmt --to-unit=G $ebsSize)
498+
EBS_SIZE=$ebsSize
499+
[ $DEBUG -eq 1 ] && echo "EBS Size: $EBS_SIZE Gb"
500+
fi
501+
502+
exit 1
503+
476504
set -ueo pipefail
477505
[ $DEBUG -eq 1 ] && set -ueox pipefail # to debug
478506
shopt -s expand_aliases
@@ -513,6 +541,8 @@ function createDockerMachine() {
513541
--amazonec2-instance-type=$AWS_EC2_TYPE \
514542
--amazonec2-spot-price=$EC2_PRICE \
515543
$DOCKER_MACHINE &
544+
545+
# --block-device-mappings "[{\"DeviceName\": \"/dev/sda1\",\"Ebs\":{\"VolumeSize\":$EBS_SIZE}}]" \
516546
}
517547

518548
if [[ "$RUN_ON" = "localhost" ]]; then

0 commit comments

Comments
 (0)