server / setup_google_drive.sh
pabla1322's picture
Upload 17 files
722781c verified
Raw
History Blame Contribute Delete
6.55 kB
#!/bin/bash
# ─────────────────────────────────────────────────────────────────────
# Alpha MC — Google Drive Backup Setup Guide
# Run this script LOCALLY (not on HuggingFace) to generate your
# GDRIVE_SA_KEY and verify everything works before uploading.
# ─────────────────────────────────────────────────────────────────────
echo ""
echo "╔══════════════════════════════════════════════════════════════╗"
echo "║ Alpha MC — Google Drive Backup Setup ║"
echo "╚══════════════════════════════════════════════════════════════╝"
echo ""
echo "Follow these steps ONE TIME to enable cloud backups:"
echo ""
echo "─────────────────────────────────────────────────────────────"
echo " STEP 1 — Create a Google Cloud Project"
echo "─────────────────────────────────────────────────────────────"
echo " 1. Go to: https://console.cloud.google.com"
echo " 2. Click 'New Project', give it any name (e.g. 'alpha-mc')"
echo " 3. Select your new project"
echo ""
echo "─────────────────────────────────────────────────────────────"
echo " STEP 2 — Enable Google Drive API"
echo "─────────────────────────────────────────────────────────────"
echo " 1. Go to: APIs & Services → Library"
echo " 2. Search for 'Google Drive API'"
echo " 3. Click Enable"
echo ""
echo "─────────────────────────────────────────────────────────────"
echo " STEP 3 — Create a Service Account"
echo "─────────────────────────────────────────────────────────────"
echo " 1. Go to: IAM & Admin → Service Accounts"
echo " 2. Click 'Create Service Account'"
echo " 3. Name it: minecraft-backup"
echo " 4. Click Done (no special roles needed)"
echo " 5. Click the new service account → Keys tab"
echo " 6. Add Key → Create new key → JSON → Download"
echo " 7. Save the downloaded file as: service-account.json"
echo ""
echo "─────────────────────────────────────────────────────────────"
echo " STEP 4 — Share your Google Drive folder with the service account"
echo "─────────────────────────────────────────────────────────────"
echo " 1. Go to Google Drive → New Folder → Name it:"
echo " 'Minecraft-Bedrock-Backups'"
echo " 2. Right-click the folder → Share"
echo " 3. Paste the service account email (from the JSON file,"
echo " it looks like: minecraft-backup@project.iam.gserviceaccount.com)"
echo " 4. Set role to 'Editor' → Share"
echo ""
echo "─────────────────────────────────────────────────────────────"
echo " STEP 5 — Generate your GDRIVE_SA_KEY secret"
echo "─────────────────────────────────────────────────────────────"
if [ -f "service-account.json" ]; then
echo " Found service-account.json — encoding..."
ENCODED=$(base64 -w 0 service-account.json)
echo ""
echo " Your GDRIVE_SA_KEY value (copy everything between the lines):"
echo " ─────────────────────────────────────────────────────────────"
echo "$ENCODED"
echo " ─────────────────────────────────────────────────────────────"
echo ""
echo " ✅ Copy the value above."
else
echo " Download service-account.json first, then run:"
echo " base64 -w 0 service-account.json"
echo " Copy the output."
fi
echo ""
echo "─────────────────────────────────────────────────────────────"
echo " STEP 6 — Add to HuggingFace Space"
echo "─────────────────────────────────────────────────────────────"
echo " 1. Go to your Space → Settings → Repository Secrets"
echo " 2. Add a new secret:"
echo " Name: GDRIVE_SA_KEY"
echo " Value: (paste the base64 string from Step 5)"
echo " 3. Restart your Space"
echo ""
echo " That's it! Backups will now upload to Google Drive"
echo " every 6 hours automatically. ✅"
echo ""
echo "─────────────────────────────────────────────────────────────"
echo " IMPORTANT: Security"
echo "─────────────────────────────────────────────────────────────"
echo " ❌ NEVER commit service-account.json to git!"
echo " ❌ NEVER upload credentials.json to HuggingFace files!"
echo " ✅ ONLY store secrets in HF Space Settings → Secrets"
echo ""