File size: 6,554 Bytes
722781c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/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 ""