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 Callback Error Updating store-trips.data - TypeError: 'float' object is not subscriptable fixed #121

Merged
Merged
Show file tree
Hide file tree
Changes from 2 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
29 changes: 24 additions & 5 deletions docker/load_mongodump.sh
TeachMeTW marked this conversation as resolved.
Show resolved Hide resolved
TeachMeTW marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,10 +1,29 @@
#!/bin/bash

# Check if the correct number of arguments is provided
if [ "$#" -ne 4 ]; then
echo "Usage: $0 <dump_file> <database_name> <docker_container_name> <collection_name>"
exit 1
fi

# Assign arguments to variables
MONGODUMP_FILE=$1
DATABASE_NAME=$2
DOCKER_CONTAINER_NAME=$3
COLLECTION_NAME=$4

echo "Copying file to docker container"
docker cp $MONGODUMP_FILE op-admin-dashboard-db-1:/tmp
# Extract the base name of the dump file for use in the restore command
FILE_NAME=$(basename "$MONGODUMP_FILE")

FILE_NAME=`basename $MONGODUMP_FILE`
# Drop the existing database to ensure it’s clean before restoring the new dump
echo "Dropping the existing database $DATABASE_NAME"
docker exec "$DOCKER_CONTAINER_NAME" mongo "$DATABASE_NAME" --eval "db.dropDatabase()"

echo "Restoring the dump from $FILE_NAME"
docker exec -e MONGODUMP_FILE=$FILE_NAME op-admin-dashboard-db-1 bash -c 'cd /tmp && tar xvf $MONGODUMP_FILE && mongorestore'
# Copy the MongoDB dump file from the local machine to the Docker container
echo "Copying file to Docker container $DOCKER_CONTAINER_NAME"
docker cp "$MONGODUMP_FILE" "$DOCKER_CONTAINER_NAME:/tmp"

# Restore the dump into the specified database
echo "Restoring the dump from $FILE_NAME to database $DATABASE_NAME"
docker exec -e MONGODUMP_FILE="$FILE_NAME" "$DOCKER_CONTAINER_NAME" bash -c \
'cd /tmp && tar xvf "$MONGODUMP_FILE" && mongorestore -d '"$DATABASE_NAME"' dump/'"$COLLECTION_NAME"''
Loading