Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix non-interactive data dumps #42

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions docker-swarm/bin/hub_create_data_dump.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,23 +60,23 @@ done

# Make sure that postgres is ready
sleep_count=0
until docker exec -i -u postgres ${container_id} pg_isready -q ; do
until docker exec -u postgres ${container_id} pg_isready -q ; do
sleep_count=$(( ${sleep_count} + 1 ))
[ ${sleep_count} -gt ${TIMEOUT} ] && fail "Database server in container ${container_id} not ready after ${TIMEOUT} seconds." 6
sleep 1
done

# Make sure that the database exists
sleep_count=0
until [ "$(docker exec -i -u postgres ${container_id} psql -A -t -c "select count(*) from pg_database where datname = '${database_name}'" postgres 2> /dev/null)" -eq 1 ] ; do
until [ "$(docker exec -u postgres ${container_id} psql -A -t -c "select count(*) from pg_database where datname = '${database_name}'" postgres 2> /dev/null)" -eq 1 ] ; do
sleep_count=$(( ${sleep_count} + 1 ))
[ ${sleep_count} -gt ${TIMEOUT} ] && fail "Database ${database_name} in container ${container_id} not ready after ${TIMEOUT} seconds." 7
sleep 1
done

# Here we go...
echo Creating a dump from the container "${container_id}" '...'
docker exec -i ${container_id} pg_dump -U blackduck -Fc -f /tmp/${database_name}.dump ${database_name}
docker exec ${container_id} pg_dump -U blackduck -Fc -f /tmp/${database_name}.dump ${database_name}
exitCode=$?
[ ${exitCode} -ne 0 ] && fail "Cannot create the dump file from the container [Container Id: ${container_id}]" 8

Expand Down Expand Up @@ -105,7 +105,6 @@ exitCode=$?
[ ${exitCode} -ne 0 ] && fail "Was not able to copy the dump file over [Container Id: ${container_id}]" 9

# After copy, remove the dump from the container.
docker exec -it ${container_id} rm /tmp/${database_name}.dump
docker exec ${container_id} rm /tmp/${database_name}.dump

echo Success with creating the dump and copying over to "[Destination Dir: $(dirname ${local_dest_dump_file})]" from the container: "[Container Id: ${container_id}]"