Created
September 8, 2025 09:47
-
-
Save thanosa75/ea9bdf761347a23d566ad981106e6804 to your computer and use it in GitHub Desktop.
Elaborate connection check for JuiceFS to B2 Backblaze connectivity.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# BackBlaze B2 Connection Test Script | |
# Run this to verify your B2 credentials and connection work before JuiceFS setup | |
echo "Testing BackBlaze B2 Connection..." | |
echo "==================================" | |
# Check environment variables | |
if [ -z "$B2_APPLICATION_KEY_ID" ] || [ -z "$B2_APPLICATION_KEY" ] || [ -z "$B2_BUCKET_NAME" ] || [ -z "$B2_ENDPOINT" ]; then | |
echo "❌ Missing environment variables. Please set:" | |
echo " export B2_APPLICATION_KEY_ID='your_key_id'" | |
echo " export B2_APPLICATION_KEY='your_application_key'" | |
echo " export B2_BUCKET_NAME='your-bucket-name'" | |
echo " export B2_ENDPOINT='https://s3.eu-central-003.backblazeb2.com'" | |
exit 1 | |
fi | |
echo "✅ Environment variables set:" | |
echo " Bucket: $B2_BUCKET_NAME" | |
echo " Endpoint: $B2_ENDPOINT" | |
echo " Key ID: ${B2_APPLICATION_KEY_ID:0:10}..." | |
echo "" | |
# Set AWS environment for testing | |
export AWS_ACCESS_KEY_ID="$B2_APPLICATION_KEY_ID" | |
export AWS_SECRET_ACCESS_KEY="$B2_APPLICATION_KEY" | |
export AWS_ENDPOINT_URL="$B2_ENDPOINT" | |
export AWS_S3_FORCE_PATH_STYLE="true" | |
# Test with aws-cli if available | |
if command -v aws >/dev/null 2>&1; then | |
echo "Testing with AWS CLI..." | |
echo "Running: aws s3 ls s3://$B2_BUCKET_NAME/ --endpoint-url $B2_ENDPOINT" | |
if aws s3 ls "s3://$B2_BUCKET_NAME/" --endpoint-url "$B2_ENDPOINT"; then | |
echo "✅ AWS CLI connection successful!" | |
else | |
echo "❌ AWS CLI connection failed" | |
echo "" | |
echo "You can install aws-cli with: apt-get install awscli" | |
fi | |
echo "" | |
else | |
echo "AWS CLI not found (optional for testing)" | |
echo "" | |
fi | |
# Test with curl | |
echo "Testing direct HTTPS connection..." | |
CURL_URL="${B2_ENDPOINT}/${B2_BUCKET_NAME}/" | |
echo "Testing: curl -I $CURL_URL" | |
if curl -I "$CURL_URL" 2>/dev/null | head -1 | grep -q "200\|403\|404"; then | |
echo "✅ HTTPS connection to endpoint successful!" | |
else | |
echo "❌ Cannot reach endpoint via HTTPS" | |
echo "Check your B2_ENDPOINT and network connectivity" | |
fi | |
echo "" | |
echo "Connection test complete." | |
echo "" | |
echo "If tests pass, try running the JuiceFS setup script again." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment