Skip to content

Commit f321da8

Browse files
committed
šŸ› Update MongoDB backup script to use connection string from environment variable
1 parent ded822d commit f321da8

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

ā€Žbackup.shā€Ž

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,8 @@ mkdir -p $BACKUP_PATH
1111

1212
echo "Starting MongoDB backup at $(date)..."
1313

14-
# Build authentication options
15-
AUTH_OPTS=""
16-
if [ -n "$MONGODB_USERNAME" ] && [ -n "$MONGODB_PASSWORD" ]; then
17-
AUTH_OPTS="--username=$MONGODB_USERNAME --password=$MONGODB_PASSWORD --authenticationDatabase=$MONGODB_AUTH_DB"
18-
fi
19-
20-
# Run mongodump to backup all databases and collections
21-
mongodump --host=$MONGODB_HOST \
22-
--port=$MONGODB_PORT \
23-
$AUTH_OPTS \
14+
# Run mongodump using the connection string from environment
15+
mongodump --uri="$MONGODB_URI" \
2416
--out=$BACKUP_PATH
2517

2618
echo "MongoDB dump completed."

0 commit comments

Comments
Ā (0)