File size: 1,505 Bytes
3eecd6b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import shutil
from pathlib import Path
import json

# Path ke backup yang ASLI (nested)
src = Path("/content/drive/MyDrive/colab_backup/project_latest/project_20260910_201145")

# --- 1. Restore /content/models ---
src_models = src / "models"
if src_models.exists():
    if Path("/content/models").exists():
        shutil.rmtree("/content/models")
    shutil.copytree(src_models, "/content/models")
    print("✓ /content/models di-restore:")
    for m in Path("/content/models").iterdir():
        size = sum(f.stat().st_size for f in m.rglob("*") if f.is_file())
        print(f"  - {m.name}  ({size/(1024*1024):.1f} MB)")
else:
    print(f"✗ {src_models} tidak ada")

# --- 2. Restore /content/config.json ---
src_cfg = src / "config.json"
if src_cfg.exists():
    shutil.copy2(src_cfg, "/content/config.json")
    print("\n✓ /content/config.json di-restore")
    with open("/content/config.json") as f:
        cfg = json.load(f)
    print(f"  Models: {list(cfg.get('models', {}).keys())}")
    print(f"  Current: {cfg.get('current_model')}")
else:
    print(f"\n✗ {src_cfg} tidak ada")

# --- 3. Restore dataset besar kalau ada ---
src_data = src / "data"
if src_data.exists():
    for f in src_data.iterdir():
        if f.is_file() and f.stat().st_size > 100000:
            dest = Path("/content/data") / f.name
            dest.parent.mkdir(parents=True, exist_ok=True)
            shutil.copy2(f, dest)
            print(f"✓ Dataset: {f.name}  ({f.stat().st_size/(1024*1024):.2f} MB)")